mirror of
https://github.com/navidrome/navidrome.git
synced 2026-10-08 02:17:25 +02:00
fix(artwork): only use disc resolution for multi-disc albums
DiscCoverArtID returns a dc- id for any track with DiscNumber>0, so serveDisc ran the full DiscArtPriority chain even for single-disc albums, where a stray disc*/ embedded image could shadow higher-priority album art. Gate disc resolution on the album having more than one disc, matching the legacy reader; single-disc tracks serve album art directly.
This commit is contained in:
parent
ce06599288
commit
ed4178a6a9
2 changed files with 24 additions and 7 deletions
|
|
@ -268,12 +268,17 @@ func (s *service) serveDisc(ctx context.Context, artID model.ArtworkID, size int
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
funcs := dr.fromDiscArtPriority(ctx, s.ffmpeg, conf.Server.DiscArtPriority)
|
// Only multi-disc albums use disc-specific resolution (matching the legacy reader); a
|
||||||
if r, path, err := selectImageReader(ctx, artID, funcs...); err == nil && r != nil {
|
// single-disc album serves album art directly, so a stray disc*/embedded image can't
|
||||||
defer r.Close()
|
// shadow higher-priority album art.
|
||||||
if data, rerr := readCapped(r); rerr == nil {
|
if len(dr.album.Discs) > 1 {
|
||||||
if hash, herr := HashImage(bytes.NewReader(data)); herr == nil {
|
funcs := dr.fromDiscArtPriority(ctx, s.ffmpeg, conf.Server.DiscArtPriority)
|
||||||
return s.serveBytes(ctx, hash, data, unixMtime(mtimeViaFS(dr.lib.FS, path)), size, square)
|
if r, path, err := selectImageReader(ctx, artID, funcs...); err == nil && r != nil {
|
||||||
|
defer r.Close()
|
||||||
|
if data, rerr := readCapped(r); rerr == nil {
|
||||||
|
if hash, herr := HashImage(bytes.NewReader(data)); herr == nil {
|
||||||
|
return s.serveBytes(ctx, hash, data, unixMtime(mtimeViaFS(dr.lib.FS, path)), size, square)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -257,7 +257,7 @@ var _ = Describe("Service", func() {
|
||||||
It("delegates a multi-disc track to its disc art, not straight to the album", func() {
|
It("delegates a multi-disc track to its disc art, not straight to the album", func() {
|
||||||
// Not embedded-eligible: the fallback must mirror CoverArtID (disc first, then album).
|
// Not embedded-eligible: the fallback must mirror CoverArtID (disc first, then album).
|
||||||
folderRepo.result = []model.Folder{{Path: "tests/fixtures/artist/an-album", ImageFiles: []string{"cover.jpg"}}}
|
folderRepo.result = []model.Folder{{Path: "tests/fixtures/artist/an-album", ImageFiles: []string{"cover.jpg"}}}
|
||||||
albumRepo.SetData(model.Albums{{ID: "aldd", Name: "Album", FolderIDs: []string{"f1"}}})
|
albumRepo.SetData(model.Albums{{ID: "aldd", Name: "Album", FolderIDs: []string{"f1"}, Discs: model.Discs{1: "One", 2: "Two"}}})
|
||||||
seedFoundStore("al", "aldd", []byte("album-art-distinct")) // album's own found art differs
|
seedFoundStore("al", "aldd", []byte("album-art-distinct")) // album's own found art differs
|
||||||
mfRepo.SetData(model.MediaFiles{{ID: "mf5", AlbumID: "aldd", DiscNumber: 1, HasCoverArt: false}})
|
mfRepo.SetData(model.MediaFiles{{ID: "mf5", AlbumID: "aldd", DiscNumber: 1, HasCoverArt: false}})
|
||||||
|
|
||||||
|
|
@ -266,6 +266,18 @@ var _ = Describe("Service", func() {
|
||||||
// The disc-folder image wins over the album's found art, proving it routed via serveDisc.
|
// The disc-folder image wins over the album's found art, proving it routed via serveDisc.
|
||||||
Expect(readAll(img)).To(Equal(coverBytes))
|
Expect(readAll(img)).To(Equal(coverBytes))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("delegates a single-disc track straight to the album, skipping disc resolution", func() {
|
||||||
|
folderRepo.result = []model.Folder{{Path: "tests/fixtures/artist/an-album", ImageFiles: []string{"cover.jpg"}}}
|
||||||
|
albumRepo.SetData(model.Albums{{ID: "alsd", Name: "Album", FolderIDs: []string{"f1"}, Discs: model.Discs{1: ""}}})
|
||||||
|
seedFoundStore("al", "alsd", []byte("album-art-distinct"))
|
||||||
|
mfRepo.SetData(model.MediaFiles{{ID: "mf6", AlbumID: "alsd", DiscNumber: 1, HasCoverArt: false}})
|
||||||
|
|
||||||
|
img, err := svc.Get(ctx, model.MustParseArtworkID("mf-mf6"), 0, false)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
// Single-disc album: album art wins; the folder disc image must not shadow it.
|
||||||
|
Expect(readAll(img)).To(Equal([]byte("album-art-distinct")))
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
Describe("disc", func() {
|
Describe("disc", func() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue