mirror of
https://github.com/navidrome/navidrome.git
synced 2026-10-12 12:27:09 +02:00
refactor(artwork): report never-evaluated candidates as skipped
This commit is contained in:
parent
62eb781e8d
commit
fe67ec68d0
2 changed files with 25 additions and 8 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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"},
|
||||
}))
|
||||
})
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue