Return album art as a Reader

This commit is contained in:
Deluan
2020-11-17 13:30:37 -05:00
parent 0aaa261a71
commit 25ae1c6cdd
5 changed files with 70 additions and 85 deletions
+5 -4
View File
@@ -1,9 +1,11 @@
package subsonic
import (
"bytes"
"context"
"errors"
"io"
"io/ioutil"
"net/http/httptest"
"github.com/deluan/navidrome/model"
@@ -67,12 +69,11 @@ type fakeArtwork struct {
recvSize int
}
func (c *fakeArtwork) Get(ctx context.Context, id string, size int, out io.Writer) error {
func (c *fakeArtwork) Get(ctx context.Context, id string, size int) (io.ReadCloser, error) {
if c.err != nil {
return c.err
return nil, c.err
}
c.recvId = id
c.recvSize = size
_, err := out.Write([]byte(c.data))
return err
return ioutil.NopCloser(bytes.NewReader([]byte(c.data))), nil
}