Don't regenerate covers if present during scan (#3646)

* Don't regenerate covers if present during scan
* Fix performer unit test (unrelated)
This commit is contained in:
WithoutPants 2023-04-07 11:57:10 +10:00 committed by GitHub
parent a6ef924d06
commit 0cd0151251
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 7 deletions

View File

@ -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

View File

@ -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

View File

@ -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) {