fix(artwork): fallback mediafile cover art to disc artwork before album (#5216)
* fix(artwork): fallback mediafile cover art to disc artwork before album Changed the mediafile cover art fallback chain to go through disc artwork before album artwork (mediafile → disc → album). Previously, mediafiles without embedded art fell back directly to album cover, bypassing any disc-specific artwork. Renamed AlbumCoverArtID() to DiscCoverArtID() to encapsulate the disc-vs-album decision in a single method, used by both CoverArtID() and the mediafile artwork reader. Signed-off-by: Deluan <deluan@navidrome.org> * fix(artwork): fix cache invalidation for mediafile and album cover art Include imagesUpdatedAt from album folders in the mediafile artwork reader's cache key, so that when a cover image file changes on disk (without audio metadata changes) the mediafile cache properly invalidates. Also include CoverArtPriority unconditionally in the album artwork reader's cache key hash, so that changing the priority order with external services disabled correctly invalidates the album cache. * fix(artwork): skip disc artwork resolution for single-disc albums Single-disc albums with DiscNumber=1 were unnecessarily routed through discArtworkReader, which does extra DB queries only to fall through to album art anyway. Now only multi-disc albums use the disc fallback path. * refactor(artwork): restore AlbumCoverArtID as a separate method Extract AlbumCoverArtID back out of DiscCoverArtID so the single-disc fallback path in reader_mediafile can reference it by name instead of inlining the artwork ID construction. --------- Signed-off-by: Deluan <deluan@navidrome.org>
This commit is contained in:
+10
-1
@@ -119,7 +119,16 @@ func (mf MediaFile) CoverArtID() ArtworkID {
|
||||
if mf.HasCoverArt && conf.Server.EnableMediaFileCoverArt {
|
||||
return artworkIDFromMediaFile(mf)
|
||||
}
|
||||
// if it does not have a coverArt, fallback to the album cover
|
||||
// Otherwise fallback to disc (if available) or album cover
|
||||
return mf.DiscCoverArtID()
|
||||
}
|
||||
|
||||
// DiscCoverArtID returns the disc artwork ID when the media file has a disc number,
|
||||
// otherwise it returns the album artwork ID.
|
||||
func (mf MediaFile) DiscCoverArtID() ArtworkID {
|
||||
if mf.DiscNumber > 0 {
|
||||
return NewArtworkID(KindDiscArtwork, DiscArtworkID(mf.AlbumID, mf.DiscNumber), nil)
|
||||
}
|
||||
return mf.AlbumCoverArtID()
|
||||
}
|
||||
|
||||
|
||||
+15
-2
@@ -504,13 +504,26 @@ var _ = Describe("MediaFile", func() {
|
||||
Expect(id.Kind).To(Equal(KindMediaFileArtwork))
|
||||
Expect(id.ID).To(Equal(mf.ID))
|
||||
})
|
||||
It("returns its album id if HasCoverArt is false", func() {
|
||||
It("returns disc art id if HasCoverArt is false and DiscNumber > 0", func() {
|
||||
mf := MediaFile{ID: "111", AlbumID: "1", HasCoverArt: false, DiscNumber: 2}
|
||||
id := mf.CoverArtID()
|
||||
Expect(id.Kind).To(Equal(KindDiscArtwork))
|
||||
Expect(id.ID).To(Equal("1:2"))
|
||||
})
|
||||
It("returns its album id if HasCoverArt is false and DiscNumber is 0", func() {
|
||||
mf := MediaFile{ID: "111", AlbumID: "1", HasCoverArt: false}
|
||||
id := mf.CoverArtID()
|
||||
Expect(id.Kind).To(Equal(KindAlbumArtwork))
|
||||
Expect(id.ID).To(Equal(mf.AlbumID))
|
||||
})
|
||||
It("returns its album id if EnableMediaFileCoverArt is disabled", func() {
|
||||
It("returns disc art id if EnableMediaFileCoverArt is disabled and DiscNumber > 0", func() {
|
||||
conf.Server.EnableMediaFileCoverArt = false
|
||||
mf := MediaFile{ID: "111", AlbumID: "1", HasCoverArt: true, DiscNumber: 3}
|
||||
id := mf.CoverArtID()
|
||||
Expect(id.Kind).To(Equal(KindDiscArtwork))
|
||||
Expect(id.ID).To(Equal("1:3"))
|
||||
})
|
||||
It("returns its album id if EnableMediaFileCoverArt is disabled and DiscNumber is 0", func() {
|
||||
conf.Server.EnableMediaFileCoverArt = false
|
||||
mf := MediaFile{ID: "111", AlbumID: "1", HasCoverArt: true}
|
||||
id := mf.CoverArtID()
|
||||
|
||||
Reference in New Issue
Block a user