From ad04cd4e4c2fc00c914dbf50df470bace5388010 Mon Sep 17 00:00:00 2001 From: Deluan Date: Mon, 4 May 2026 07:23:20 -0400 Subject: [PATCH] fix(artwork): simplify lastUpdate logic using TimeNewest utility Signed-off-by: Deluan --- core/artwork/reader_album.go | 10 ++++------ core/artwork/reader_disc.go | 10 ++++------ 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/core/artwork/reader_album.go b/core/artwork/reader_album.go index 680ce2349..73ba9b5ee 100644 --- a/core/artwork/reader_album.go +++ b/core/artwork/reader_album.go @@ -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 } diff --git a/core/artwork/reader_disc.go b/core/artwork/reader_disc.go index 9140d6f1e..0f648c987 100644 --- a/core/artwork/reader_disc.go +++ b/core/artwork/reader_disc.go @@ -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 }