🎧 Your Personal Streaming Service
Go airsonicmadsonicmedia-servermusicmusic-servernavidromeopensubsonicraspberry-piself-hostedstreamerstreaming-apistreaming-audiosubsonicsubsonic-server
refactor: when resizing, don't buffer the original image "just in case"
Deluan81edef925c52
diff --git a/core/artwork/reader_resized.go b/core/artwork/reader_resized.goindex d89c83d5c..46d0f8866 100644--- a/core/artwork/reader_resized.go+++ b/core/artwork/reader_resized.go@@ -59,13 +59,9 @@ func (a *resizedArtworkReader) Reader(ctx context.Context) (io.ReadCloser, strinif err != nil {return nil, "", err}-- // Keep a copy of the original data. In case we can't resize it, send it as is- buf := new(bytes.Buffer)- r := io.TeeReader(orig, buf)defer orig.Close()- resized, origSize, err := resizeImage(r, a.size, a.square)+ resized, origSize, err := resizeImage(orig, a.size, a.square)if resized == nil {log.Trace(ctx, "Image smaller than requested size", "artID", a.artID, "original", origSize, "resized", a.size)} else {@@ -75,9 +71,9 @@ func (a *resizedArtworkReader) Reader(ctx context.Context) (io.ReadCloser, strinlog.Warn(ctx, "Could not resize image. Will return image as is", "artID", a.artID, "size", a.size, err)}if err != nil || resized == nil {- // Force finish reading any remaining data- _, _ = io.Copy(io.Discard, r)- return io.NopCloser(buf), "", nil //nolint:nilerr+ // if we couldn't resize the image, return the original+ orig, _, err = a.a.Get(ctx, a.artID, 0, false)+ return orig, "", err}return io.NopCloser(resized), fmt.Sprintf("%s@%d", a.artID, a.size), nil}