fix(artwork): simplify lastUpdate logic using TimeNewest utility

Signed-off-by: Deluan <deluan@navidrome.org>
This commit is contained in:
Deluan 2026-05-04 07:23:20 -04:00
parent 5bb4e90911
commit ad04cd4e4c
2 changed files with 8 additions and 12 deletions

View File

@ -18,6 +18,7 @@ import (
"github.com/navidrome/navidrome/core/ffmpeg"
"github.com/navidrome/navidrome/log"
"github.com/navidrome/navidrome/model"
"github.com/navidrome/navidrome/utils"
"github.com/navidrome/navidrome/utils/natural"
)
@ -53,12 +54,9 @@ func newAlbumArtworkReader(ctx context.Context, artwork *artwork, artID model.Ar
lib: lib,
}
a.cacheKey.artID = artID
a.cacheKey.lastUpdate = al.UpdatedAt
if a.updatedAt != nil && a.updatedAt.After(a.cacheKey.lastUpdate) {
a.cacheKey.lastUpdate = *a.updatedAt
}
if al.ImportedAt.After(a.cacheKey.lastUpdate) {
a.cacheKey.lastUpdate = al.ImportedAt
a.cacheKey.lastUpdate = utils.TimeNewest(al.UpdatedAt, al.ImportedAt)
if imagesUpdateAt != nil {
a.cacheKey.lastUpdate = utils.TimeNewest(a.cacheKey.lastUpdate, *imagesUpdateAt)
}
return a, nil
}

View File

@ -16,6 +16,7 @@ import (
"github.com/navidrome/navidrome/core/ffmpeg"
"github.com/navidrome/navidrome/log"
"github.com/navidrome/navidrome/model"
"github.com/navidrome/navidrome/utils"
)
type discArtworkReader struct {
@ -105,12 +106,9 @@ func newDiscArtworkReader(ctx context.Context, a *artwork, artID model.ArtworkID
updatedAt: imagesUpdatedAt,
}
r.cacheKey.artID = artID
r.cacheKey.lastUpdate = al.UpdatedAt
if r.updatedAt != nil && r.updatedAt.After(r.cacheKey.lastUpdate) {
r.cacheKey.lastUpdate = *r.updatedAt
}
if al.ImportedAt.After(r.cacheKey.lastUpdate) {
r.cacheKey.lastUpdate = al.ImportedAt
r.cacheKey.lastUpdate = utils.TimeNewest(al.UpdatedAt, al.ImportedAt)
if imagesUpdatedAt != nil {
r.cacheKey.lastUpdate = utils.TimeNewest(r.cacheKey.lastUpdate, *imagesUpdatedAt)
}
return r, nil
}