Skip to content

Commit

Permalink
Don't regenerate covers if present during scan (#3646)
Browse files Browse the repository at this point in the history
* Don't regenerate covers if present during scan
* Fix performer unit test (unrelated)
  • Loading branch information
WithoutPants authored Apr 7, 2023
1 parent a6ef924 commit 0cd0151
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
7 changes: 7 additions & 0 deletions internal/manager/task_generate_screenshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,19 @@ func (t *GenerateCoverTask) GetDescription() string {
func (t *GenerateCoverTask) Start(ctx context.Context) {
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
Expand Down
7 changes: 5 additions & 2 deletions pkg/sqlite/performer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1114,11 +1114,14 @@ func verifyPerformerAge(t *testing.T, ageCriterion models.IntCriterionInput) {

d := performer.Birthdate.Time
age := cd.Year() - d.Year()
if cd.YearDay() < d.YearDay() {
// using YearDay screws up on leap years
if cd.Month() < d.Month() || (cd.Month() == d.Month() && cd.Day() < d.Day()) {
age = age - 1
}

verifyInt(t, age, ageCriterion)
if !verifyInt(t, age, ageCriterion) {
t.Errorf("Performer birthdate: %s, deathdate: %s", performer.Birthdate.String(), performer.DeathDate.String())
}
}

return nil
Expand Down
12 changes: 7 additions & 5 deletions pkg/sqlite/scene_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2836,21 +2836,23 @@ func verifyScenesOCounter(t *testing.T, oCounterCriterion models.IntCriterionInp
})
}

func verifyInt(t *testing.T, value int, criterion models.IntCriterionInput) {
func verifyInt(t *testing.T, value int, criterion models.IntCriterionInput) bool {
t.Helper()
assert := assert.New(t)
if criterion.Modifier == models.CriterionModifierEquals {
assert.Equal(criterion.Value, value)
return assert.Equal(criterion.Value, value)
}
if criterion.Modifier == models.CriterionModifierNotEquals {
assert.NotEqual(criterion.Value, value)
return assert.NotEqual(criterion.Value, value)
}
if criterion.Modifier == models.CriterionModifierGreaterThan {
assert.Greater(value, criterion.Value)
return assert.Greater(value, criterion.Value)
}
if criterion.Modifier == models.CriterionModifierLessThan {
assert.Less(value, criterion.Value)
return assert.Less(value, criterion.Value)
}

return true
}

func TestSceneQueryDuration(t *testing.T) {
Expand Down

0 comments on commit 0cd0151

Please sign in to comment.