From fe67ec68d0a23b818f03997dba2090bd8ad6d326 Mon Sep 17 00:00:00 2001 From: Deluan Date: Fri, 14 Aug 2026 12:35:26 -0400 Subject: [PATCH] refactor(artwork): report never-evaluated candidates as skipped --- core/artwork/resolve.go | 8 ++++---- core/artwork/trace_test.go | 25 +++++++++++++++++++++---- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/core/artwork/resolve.go b/core/artwork/resolve.go index c9b11a833..b115c23a8 100644 --- a/core/artwork/resolve.go +++ b/core/artwork/resolve.go @@ -165,7 +165,7 @@ func (r *resolver) resolveAlbum(ctx context.Context, albumID string) (resolution return res, nil } default: - chain.record(pattern, outcomeMiss, "no images in album folder") + chain.record(pattern, outcomeSkipped, "no images in album folder") } } return chain.exhausted(), nil @@ -233,7 +233,7 @@ func (r *resolver) resolveArtist(ctx context.Context, artistID string) (resoluti } case strings.HasPrefix(pattern, "album/"): if lib.FS == nil { - chain.record(pattern, outcomeMiss, "artist has no albums") + chain.record(pattern, outcomeSkipped, "artist has no albums") continue } res, ok := resolveFolderFile(ctx, lib, imgFiles, strings.TrimPrefix(pattern, "album/")) @@ -242,11 +242,11 @@ func (r *resolver) resolveArtist(ctx context.Context, artistID string) (resoluti } default: if lib.FS == nil { - chain.record(pattern, outcomeMiss, "artist has no albums") + chain.record(pattern, outcomeSkipped, "artist has no albums") continue } if artistFolder == "" { - chain.record(pattern, outcomeMiss, "no artist folder") + chain.record(pattern, outcomeSkipped, "no artist folder") continue } res, ok := resolveArtistFolderPattern(ctx, lib, artistFolder, pattern) diff --git a/core/artwork/trace_test.go b/core/artwork/trace_test.go index ba22415dd..b772df71d 100644 --- a/core/artwork/trace_test.go +++ b/core/artwork/trace_test.go @@ -144,12 +144,29 @@ var _ = Describe("resolveAlbum tracing", func() { defer res.reader.Close() Expect(t.Steps()).To(HaveLen(2), "a configured pattern must appear even when the chain never evaluated it") Expect(t.Steps()[0]).To(Equal(traceStep{ - Candidate: "cover.jpg", Outcome: outcomeMiss, Detail: "no images in album folder", + Candidate: "cover.jpg", Outcome: outcomeSkipped, Detail: "no images in album folder", })) Expect(t.Steps()[1].Candidate).To(Equal("embedded")) Expect(t.Steps()[1].Outcome).To(Equal(outcomeHit)) }) + It("records an evaluated pattern that matched nothing as a miss, not a skip", func() { + folderRepo.result = []model.Folder{{ + Path: "tests/fixtures/artist/an-album", + ImageFiles: []string{"artist.png"}, + }} + albumRepo.SetData(model.Albums{ + {ID: "al3", Name: "Album", EmbedArtPath: "tests/fixtures/artist/an-album/test.mp3", FolderIDs: []string{"f1"}}, + }) + + res, err := newResolver(ds, ag, ffm, nil).resolve(ctx, model.ArtworkQueueItem{ItemKind: "al", ItemID: "al3"}) + Expect(err).ToNot(HaveOccurred()) + Expect(res.reader).ToNot(BeNil()) + defer res.reader.Close() + Expect(t.Steps()[0]).To(Equal(traceStep{Candidate: "cover.jpg", Outcome: outcomeMiss}), + "the folder was searched and held no cover.jpg, which is not the same as never looking") + }) + It("ignores an empty priority token", func() { conf.Server.CoverArtPriority = "cover.jpg," albumRepo.SetData(model.Albums{{ID: "al2", Name: "Album", FolderIDs: []string{"f1"}}}) @@ -157,7 +174,7 @@ var _ = Describe("resolveAlbum tracing", func() { _, err := newResolver(ds, ag, ffm, nil).resolve(ctx, model.ArtworkQueueItem{ItemKind: "al", ItemID: "al2"}) Expect(err).ToNot(HaveOccurred()) Expect(t.Steps()).To(Equal([]traceStep{ - {Candidate: "cover.jpg", Outcome: outcomeMiss, Detail: "no images in album folder"}, + {Candidate: "cover.jpg", Outcome: outcomeSkipped, Detail: "no images in album folder"}, })) }) }) @@ -252,7 +269,7 @@ var _ = Describe("resolveArtist tracing", func() { Expect(err).ToNot(HaveOccurred()) Expect(t.Steps()).To(Equal([]traceStep{ {Candidate: "upload", Outcome: outcomeMiss}, - {Candidate: "album/artist.*", Outcome: outcomeMiss, Detail: "artist has no albums"}, + {Candidate: "album/artist.*", Outcome: outcomeSkipped, Detail: "artist has no albums"}, }), "a configured pattern that was never evaluated must still appear, and say why") }) @@ -265,7 +282,7 @@ var _ = Describe("resolveArtist tracing", func() { Expect(err).ToNot(HaveOccurred()) Expect(t.Steps()).To(Equal([]traceStep{ {Candidate: "upload", Outcome: outcomeMiss}, - {Candidate: "artist.*", Outcome: outcomeMiss, Detail: "no artist folder"}, + {Candidate: "artist.*", Outcome: outcomeSkipped, Detail: "no artist folder"}, })) })