Add timeout for artwork extraction

This commit is contained in:
Deluan 2022-12-25 01:25:10 -05:00 committed by Deluan Quintão
parent 52a4721c91
commit 8cf78efb9c

View file

@ -17,6 +17,7 @@ import (
"reflect" "reflect"
"runtime" "runtime"
"strings" "strings"
"time"
"github.com/dhowden/tag" "github.com/dhowden/tag"
"github.com/disintegration/imaging" "github.com/disintegration/imaging"
@ -46,6 +47,9 @@ type artwork struct {
} }
func (a *artwork) Get(ctx context.Context, id string, size int) (io.ReadCloser, error) { func (a *artwork) Get(ctx context.Context, id string, size int) (io.ReadCloser, error) {
ctx, cancel := context.WithTimeout(ctx, 10*time.Second)
defer cancel()
var artID model.ArtworkID var artID model.ArtworkID
var err error var err error
if id != "" { if id != "" {