mirror of
https://github.com/navidrome/navidrome.git
synced 2026-11-21 01:19:58 +01:00
fix: bust song/disc artwork ids and disc thumbnails on cover changes
Song coverArt ids emitted to Subsonic clients embedded no timestamp for the disc/album fallback paths (always `_0`), so clients that cache by coverArt id kept stale art after an album cover upload or delete. Fold the song's CoverArtUpdatedAt into DiscCoverArtID and AlbumCoverArtID; ids are unchanged when no cover was ever uploaded. The web UI disc-header thumbnails had the same gap: getDiscCoverArtUrl only used the song's updatedAt. It now takes the record and picks the newest of updatedAt/coverArtUpdatedAt, sharing the cache-key helper with getCoverArtUrl.
This commit is contained in:
parent
e8946b8810
commit
223efdf020
5 changed files with 58 additions and 29 deletions
|
|
@ -132,13 +132,13 @@ func (mf MediaFile) CoverArtID() ArtworkID {
|
|||
// 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 NewArtworkID(KindDiscArtwork, DiscArtworkID(mf.AlbumID, mf.DiscNumber), mf.CoverArtUpdatedAt)
|
||||
}
|
||||
return mf.AlbumCoverArtID()
|
||||
}
|
||||
|
||||
func (mf MediaFile) AlbumCoverArtID() ArtworkID {
|
||||
return artworkIDFromAlbum(Album{ID: mf.AlbumID})
|
||||
return artworkIDFromAlbum(Album{ID: mf.AlbumID, CoverArtUpdatedAt: mf.CoverArtUpdatedAt})
|
||||
}
|
||||
|
||||
func (mf MediaFile) StructuredLyrics() (LyricList, error) {
|
||||
|
|
|
|||
|
|
@ -549,6 +549,19 @@ var _ = Describe("MediaFile", func() {
|
|||
Expect(id.Kind).To(Equal(KindAlbumArtwork))
|
||||
Expect(id.ID).To(Equal(mf.AlbumID))
|
||||
})
|
||||
It("folds CoverArtUpdatedAt into disc and album fallback ids", func() {
|
||||
stamp := time.Date(2026, 7, 17, 0, 0, 0, 0, time.UTC)
|
||||
disc := MediaFile{ID: "111", AlbumID: "1", DiscNumber: 2}
|
||||
album := MediaFile{ID: "111", AlbumID: "1"}
|
||||
Expect(disc.CoverArtID().String()).To(HaveSuffix("_0"))
|
||||
Expect(album.CoverArtID().String()).To(HaveSuffix("_0"))
|
||||
disc.CoverArtUpdatedAt = &stamp
|
||||
album.CoverArtUpdatedAt = &stamp
|
||||
Expect(disc.CoverArtID().LastUpdate).To(Equal(stamp))
|
||||
Expect(disc.CoverArtID().String()).ToNot(HaveSuffix("_0"))
|
||||
Expect(album.CoverArtID().LastUpdate).To(Equal(stamp))
|
||||
Expect(album.CoverArtID().String()).ToNot(HaveSuffix("_0"))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("AudioCodec", func() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue