diff --git a/core/artwork/worker.go b/core/artwork/worker.go index 3f280c034..03f2aca86 100644 --- a/core/artwork/worker.go +++ b/core/artwork/worker.go @@ -319,9 +319,11 @@ func (w *Worker) precache(ctx context.Context, got *acquired) { return } // Same key as the serving path (hash/size/square); only the source of the bytes differs. + // square matches what the list surfaces request, otherwise this warms a key nothing reads. item := &resizedItem{ hash: got.ia.Hash, size: conf.Server.UICoverArtSize, + square: true, lastUpdate: got.ia.UpdatedAt, ffmpeg: w.deps.ffmpeg, open: func() (io.ReadCloser, error) { return io.NopCloser(bytes.NewReader(got.data)), nil }, diff --git a/core/artwork/worker_test.go b/core/artwork/worker_test.go index 54ac5d09f..af76cefc3 100644 --- a/core/artwork/worker_test.go +++ b/core/artwork/worker_test.go @@ -562,7 +562,8 @@ var _ = Describe("Worker", func() { Expect(err).ToNot(HaveOccurred()) Expect(n).To(Equal(1)) - Expect(imgCache.getKeys()).To(ContainElement(ContainSubstring(".300.false."))) + // The list surfaces request square covers, so warming any other key is wasted work. + Expect(imgCache.getKeys()).To(ContainElement(ContainSubstring(".300.true."))) }) It("skips warming when precache is disabled", func() { @@ -593,7 +594,7 @@ var _ = Describe("Worker", func() { // from the bytes handed in. Probing with a source that refuses to open proves it // is really cached rather than re-read on demand. probe := &resizedItem{ - hash: ia.Hash, size: 300, lastUpdate: ia.UpdatedAt, ffmpeg: ffm, + hash: ia.Hash, size: 300, square: true, lastUpdate: ia.UpdatedAt, ffmpeg: ffm, open: func() (io.ReadCloser, error) { return nil, errors.New("precache must not re-read the source") }, } stream, err := imgCache.Get(ctx, probe)