Fix image stuttering (#3035)
* Fix image stuttering. * Fix docker publishing for PRs * Write tests for new square parameter. * Simplify code for createImage. --------- Co-authored-by: Deluan Quintão <deluan@navidrome.org>
This commit is contained in:
@@ -36,7 +36,7 @@ func (pub *Router) handleImages(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
size := p.IntOr("size", 0)
|
||||
|
||||
imgReader, lastUpdate, err := pub.artwork.Get(ctx, artId, size)
|
||||
imgReader, lastUpdate, err := pub.artwork.Get(ctx, artId, size, false)
|
||||
switch {
|
||||
case errors.Is(err, context.Canceled):
|
||||
return
|
||||
|
||||
@@ -64,8 +64,9 @@ func (api *Router) GetCoverArt(w http.ResponseWriter, r *http.Request) (*respons
|
||||
p := req.Params(r)
|
||||
id, _ := p.String("id")
|
||||
size := p.IntOr("size", 0)
|
||||
square := p.BoolOr("square", false)
|
||||
|
||||
imgReader, lastUpdate, err := api.artwork.GetOrPlaceholder(ctx, id, size)
|
||||
imgReader, lastUpdate, err := api.artwork.GetOrPlaceholder(ctx, id, size, square)
|
||||
w.Header().Set("cache-control", "public, max-age=315360000")
|
||||
w.Header().Set("last-modified", lastUpdate.Format(time.RFC1123))
|
||||
|
||||
|
||||
@@ -257,7 +257,7 @@ type fakeArtwork struct {
|
||||
recvSize int
|
||||
}
|
||||
|
||||
func (c *fakeArtwork) GetOrPlaceholder(_ context.Context, id string, size int) (io.ReadCloser, time.Time, error) {
|
||||
func (c *fakeArtwork) GetOrPlaceholder(_ context.Context, id string, size int, square bool) (io.ReadCloser, time.Time, error) {
|
||||
if c.err != nil {
|
||||
return nil, time.Time{}, c.err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user