Fix generate task override behaviour (#3661)

This commit is contained in:
DingDongSoLong4
2023-05-03 05:42:25 +02:00
committed by GitHub
parent 1717474a81
commit 67a2161c62
9 changed files with 96 additions and 51 deletions

View File

@@ -21,21 +21,18 @@ func (t *GenerateCoverTask) GetDescription() string {
}
func (t *GenerateCoverTask) Start(ctx context.Context) {
if !t.required(ctx) {
return
}
scenePath := t.Scene.Path
var required bool
if err := t.txnManager.WithReadTxn(ctx, func(ctx context.Context) error {
// don't generate the screenshot if it already exists
required = t.required(ctx)
return t.Scene.LoadPrimaryFile(ctx, t.txnManager.File)
}); err != nil {
logger.Error(err)
}
if !required {
return
}
videoFile := t.Scene.Files.Primary()
if videoFile == nil {
return
@@ -92,7 +89,11 @@ func (t *GenerateCoverTask) Start(ctx context.Context) {
}
// required returns true if the sprite needs to be generated
func (t GenerateCoverTask) required(ctx context.Context) bool {
func (t *GenerateCoverTask) required(ctx context.Context) bool {
if t.Scene.Path == "" {
return false
}
if t.Overwrite {
return true
}