mirror of
https://github.com/navidrome/navidrome.git
synced 2026-08-01 07:21:17 +00:00
fix(playlist): expose cover cache-buster on single-track reads
The playlist single-track Read select was missing the cover_art_updated_at scalar that the list query carries, so a getOne (e.g. after rating a track) replaced the cached UI record with one lacking the cover cache-buster, reverting song art to the stale URL until the list reloaded.
This commit is contained in:
parent
ee7c4d3b88
commit
f4c1431bdf
@ -108,6 +108,7 @@ func (r *playlistTrackRepository) Read(id string) (any, error) {
|
||||
"rated_at",
|
||||
"f.*",
|
||||
"playlist_tracks.*",
|
||||
"(select cover_art_updated_at from album where album.id = f.album_id) as cover_art_updated_at",
|
||||
).
|
||||
Join("media_file f on f.id = media_file_id").
|
||||
Where(And{Eq{"playlist_id": r.playlistId}, Eq{"playlist_tracks.id": id}})
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package persistence
|
||||
|
||||
import (
|
||||
"github.com/Masterminds/squirrel"
|
||||
"github.com/navidrome/navidrome/log"
|
||||
"github.com/navidrome/navidrome/model"
|
||||
"github.com/navidrome/navidrome/model/request"
|
||||
@ -37,6 +38,30 @@ var _ = Describe("PlaylistTrackRepository", func() {
|
||||
})
|
||||
})
|
||||
|
||||
Describe("Read", func() {
|
||||
It("exposes the album's cover timestamp on a single track", func() {
|
||||
tracks, err := repo.GetAll(model.QueryOptions{Sort: "id"})
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(tracks).ToNot(BeEmpty())
|
||||
albumID := tracks[0].AlbumID
|
||||
|
||||
albumRepo := NewAlbumRepository(request.WithUser(GinkgoT().Context(), model.User{ID: "userid"}), GetDBXBuilder()).(*albumRepository)
|
||||
Expect(albumRepo.UpdateImage(albumID, "cover-read.jpg")).To(Succeed())
|
||||
DeferCleanup(func() {
|
||||
// Restore both columns so fixture-equality tests stay untouched
|
||||
_, _ = albumRepo.executeSQL(squirrel.Update("album").
|
||||
Set("uploaded_image", "").Set("cover_art_updated_at", nil).
|
||||
Where(squirrel.Eq{"id": albumID}))
|
||||
})
|
||||
|
||||
got, err := repo.Read(tracks[0].ID)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
trk, ok := got.(*model.PlaylistTrack)
|
||||
Expect(ok).To(BeTrue())
|
||||
Expect(trk.CoverArtUpdatedAt).ToNot(BeNil())
|
||||
})
|
||||
})
|
||||
|
||||
Describe("CountAll", func() {
|
||||
It("returns the number of tracks in the playlist", func() {
|
||||
Expect(repo.CountAll()).To(Equal(int64(2)))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user