mirror of
https://github.com/navidrome/navidrome.git
synced 2026-08-01 07:21:17 +00:00
fix(artwork): clear the stored hash when the artwork source disappears
A removed cover made Get error with ErrUnavailable before the enqueue, so the worker never saw the entity and the stale hash kept being emitted. The unavailable path now enqueues too; the worker's reader signal carries the folder change and the existing no-result clearing applies. Covered by an e2e spec exercising the full disappear-and-clear flow.
This commit is contained in:
parent
0e74cf0ab1
commit
a7eec3afc3
@ -80,6 +80,11 @@ func (a *artwork) Get(ctx context.Context, artID model.ArtworkID, size int, squa
|
||||
if !errors.Is(err, context.Canceled) && !errors.Is(err, ErrUnavailable) {
|
||||
log.Error(ctx, "Error accessing image cache", "id", artID, "size", size, err)
|
||||
}
|
||||
// A vanished source must still reach the worker, or a stored hash would keep describing
|
||||
// artwork that no longer exists.
|
||||
if a.blurHashes != nil && errors.Is(err, ErrUnavailable) {
|
||||
a.blurHashes.Enqueue(artID, artReader.LastUpdated(), false)
|
||||
}
|
||||
return nil, time.Time{}, err
|
||||
}
|
||||
if a.blurHashes != nil {
|
||||
|
||||
@ -35,6 +35,34 @@ var _ = Describe("BlurHash", func() {
|
||||
}, "10s", "100ms").Should(Succeed())
|
||||
})
|
||||
|
||||
It("clears the stored blurhash when the cover disappears", func() {
|
||||
setLayout(fstest.MapFS{
|
||||
"Artist/Album/01 - Song.mp3": trackFile(1, "Song"),
|
||||
"Artist/Album/cover.png": realPNG("vanishing-cover"),
|
||||
})
|
||||
scan()
|
||||
al := firstAlbum()
|
||||
readArtwork(al.CoverArtID())
|
||||
Eventually(func(g Gomega) {
|
||||
updated, err := ds.Album(ctx).Get(al.ID)
|
||||
g.Expect(err).ToNot(HaveOccurred())
|
||||
g.Expect(updated.BlurHash).ToNot(BeEmpty())
|
||||
}, "10s", "100ms").Should(Succeed())
|
||||
|
||||
setLayout(fstest.MapFS{
|
||||
"Artist/Album/01 - Song.mp3": trackFile(1, "Song"),
|
||||
})
|
||||
scan()
|
||||
_, err := readArtworkOrErr(al.CoverArtID())
|
||||
Expect(err).To(HaveOccurred())
|
||||
|
||||
Eventually(func(g Gomega) {
|
||||
updated, err := ds.Album(ctx).Get(al.ID)
|
||||
g.Expect(err).ToNot(HaveOccurred())
|
||||
g.Expect(updated.BlurHash).To(BeEmpty())
|
||||
}, "10s", "100ms").Should(Succeed())
|
||||
})
|
||||
|
||||
It("does not persist a blurhash when the served image cannot be decoded", func() {
|
||||
setLayout(fstest.MapFS{
|
||||
"Artist/Album/01 - Song.mp3": trackFile(1, "Song"),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user