Fix cover generation error

This commit is contained in:
WithoutPants 2023-05-04 08:24:58 +10:00 committed by GitHub
parent 79bc5c914f
commit f3f7ee7fd2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -21,17 +21,20 @@ func (t *GenerateCoverTask) GetDescription() string {
} }
func (t *GenerateCoverTask) Start(ctx context.Context) { func (t *GenerateCoverTask) Start(ctx context.Context) {
if !t.required(ctx) {
return
}
scenePath := t.Scene.Path scenePath := t.Scene.Path
var required bool
if err := t.txnManager.WithReadTxn(ctx, func(ctx context.Context) error { if err := t.txnManager.WithReadTxn(ctx, func(ctx context.Context) error {
required = t.required(ctx)
return t.Scene.LoadPrimaryFile(ctx, t.txnManager.File) return t.Scene.LoadPrimaryFile(ctx, t.txnManager.File)
}); err != nil { }); err != nil {
logger.Error(err) logger.Error(err)
} }
if !required {
return
}
videoFile := t.Scene.Files.Primary() videoFile := t.Scene.Files.Primary()
if videoFile == nil { if videoFile == nil {
@ -89,6 +92,7 @@ func (t *GenerateCoverTask) Start(ctx context.Context) {
} }
// required returns true if the sprite needs to be generated // required returns true if the sprite needs to be generated
// assumes in a transaction
func (t *GenerateCoverTask) required(ctx context.Context) bool { func (t *GenerateCoverTask) required(ctx context.Context) bool {
if t.Scene.Path == "" { if t.Scene.Path == "" {
return false return false