From 04c00fa7ed2fa53214d29a1ccdfb21c7c169b867 Mon Sep 17 00:00:00 2001 From: Deluan Date: Sun, 26 Jul 2026 14:50:30 -0400 Subject: [PATCH] refactor(artwork): move fingerprint property key const to `consts` package Signed-off-by: Deluan --- consts/consts.go | 3 +++ core/artwork/housekeeping.go | 9 +++------ core/artwork/housekeeping_test.go | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/consts/consts.go b/consts/consts.go index 0a244f55f..d7f662cd8 100644 --- a/consts/consts.go +++ b/consts/consts.go @@ -24,6 +24,9 @@ const ( LastDBAnalyzeAttemptAtKey = "LastDBAnalyzeAttemptAt" DBAnalyzePendingKey = "DBAnalyzePending" DBAnalyzeFailureCountKey = "DBAnalyzeFailureCount" + // ArtConfFingerprintPropertyKey is the model.PropertyRepository key Backfill compares against + // to detect artwork-affecting config changes across restarts. + ArtConfFingerprintPropertyKey = "artwork.fingerprint" UIAuthorizationHeader = "X-ND-Authorization" UIClientUniqueIDHeader = "X-ND-Client-Unique-Id" diff --git a/core/artwork/housekeeping.go b/core/artwork/housekeeping.go index 99172f017..3f0e98bad 100644 --- a/core/artwork/housekeeping.go +++ b/core/artwork/housekeeping.go @@ -8,15 +8,12 @@ import ( "time" "github.com/navidrome/navidrome/conf" + "github.com/navidrome/navidrome/consts" "github.com/navidrome/navidrome/core/auth" "github.com/navidrome/navidrome/log" "github.com/navidrome/navidrome/model" ) -// FingerprintPropertyKey is the model.PropertyRepository key Backfill compares against -// to detect artwork-affecting config changes across restarts. -const FingerprintPropertyKey = "artwork.fingerprint" - // staleAbsentAge is how old an absent resolution must be before the recheck job retries it. const staleAbsentAge = 24 * time.Hour @@ -46,7 +43,7 @@ func Backfill(ctx context.Context, ds model.DataStore) (bool, error) { ctx = auth.WithAdminUser(ctx, ds) current := Fingerprint() props := ds.Property(ctx) - stored, err := props.DefaultGet(FingerprintPropertyKey, "") + stored, err := props.DefaultGet(consts.ArtConfFingerprintPropertyKey, "") if err != nil { return false, err } @@ -74,7 +71,7 @@ func Backfill(ctx context.Context, ds model.DataStore) (bool, error) { } } - if err := props.Put(FingerprintPropertyKey, current); err != nil { + if err := props.Put(consts.ArtConfFingerprintPropertyKey, current); err != nil { return false, err } log.Info(ctx, "Artwork: config fingerprint changed, backfill enqueued") diff --git a/core/artwork/housekeeping_test.go b/core/artwork/housekeeping_test.go index cd182ca22..f61bf652d 100644 --- a/core/artwork/housekeeping_test.go +++ b/core/artwork/housekeeping_test.go @@ -125,7 +125,7 @@ var _ = Describe("Housekeeping", func() { Describe("Backfill", func() { It("enqueues nothing and returns false when the stored fingerprint matches", func() { seedEntities() - Expect(propRepo.Put(FingerprintPropertyKey, Fingerprint())).To(Succeed()) + Expect(propRepo.Put(consts.ArtConfFingerprintPropertyKey, Fingerprint())).To(Succeed()) did, err := Backfill(ctx, ds) Expect(err).ToNot(HaveOccurred()) @@ -147,7 +147,7 @@ var _ = Describe("Housekeeping", func() { Expect(err).ToNot(HaveOccurred()) Expect(count).To(Equal(int64(5))) // 2 artists + 1 album + 1 playlist + 1 radio - stored, err := propRepo.Get(FingerprintPropertyKey) + stored, err := propRepo.Get(consts.ArtConfFingerprintPropertyKey) Expect(err).ToNot(HaveOccurred()) Expect(stored).To(Equal(Fingerprint())) }) @@ -168,7 +168,7 @@ var _ = Describe("Housekeeping", func() { It("enqueues artists before albums/playlists/radios, all at Backfill priority", func() { seedEntities() - Expect(propRepo.Put(FingerprintPropertyKey, "stale-fingerprint")).To(Succeed()) + Expect(propRepo.Put(consts.ArtConfFingerprintPropertyKey, "stale-fingerprint")).To(Succeed()) did, err := Backfill(ctx, ds) Expect(err).ToNot(HaveOccurred())