🎧 Your Personal Streaming Service
Go airsonicmadsonicmedia-servermusicmusic-servernavidromeopensubsonicraspberry-piself-hostedstreamerstreaming-apistreaming-audiosubsonicsubsonic-server
Also caches resized images
Deluane89d99aee0e0
diff --git a/core/artwork.go b/core/artwork.goindex b6b1b0b77..a0db2d2f6 100644--- a/core/artwork.go+++ b/core/artwork.go@@ -55,17 +55,6 @@ func (a *artwork) Get(ctx context.Context, id string, size int) (io.ReadCloser,}}- // If requested a resized image, get the original (possibly from cache)- if size > 0 && id != "" {- r, err := a.Get(ctx, id, 0)- if err != nil {- return nil, err- }- defer r.Close()- resized, err := a.resizedFromOriginal(ctx, artID, r, size)- return io.NopCloser(resized), err- }-key := &artworkKey{a: a, artID: artID, size: size}r, err := a.cache.Get(ctx, key)@@ -85,6 +74,17 @@ func (f fromFunc) String() string {}func (a *artwork) get(ctx context.Context, artID model.ArtworkID, size int) (reader io.ReadCloser, path string, err error) {+ // If requested a resized image, get the original (possibly from cache)+ if size > 0 {+ r, err := a.Get(ctx, artID.String(), 0)+ if err != nil {+ return nil, "", err+ }+ defer r.Close()+ resized, err := a.resizedFromOriginal(ctx, artID, r, size)+ return io.NopCloser(resized), fmt.Sprintf("%s@%d", artID, size), err+ }+switch artID.Kind {case model.KindAlbumArtwork:reader, path = a.extractAlbumImage(ctx, artID)diff --git a/core/artwork_internal_test.go b/core/artwork_internal_test.goindex 725aa18c7..3488c81a6 100644--- a/core/artwork_internal_test.go+++ b/core/artwork_internal_test.go@@ -183,7 +183,7 @@ var _ = Describe("Artwork", func() {})It("returns a JPEG if original image is not a PNG", func() {conf.Server.CoverArtPriority = "cover.jpg"- r, err := aw.Get(context.Background(), alMultipleCovers.CoverArtID().String(), 200)+ r, _, err := aw.get(context.Background(), alMultipleCovers.CoverArtID(), 200)Expect(err).ToNot(HaveOccurred())br, format, err := asImageReader(r)