From 7baa97ae24ae75f92a85fd790022528c1bf3eba8 Mon Sep 17 00:00:00 2001 From: hadrien Date: Mon, 18 Sep 2023 15:20:10 +0200 Subject: [PATCH] add missing context --- engine/backend/gifsicle.go | 2 +- image/factory.go | 4 ++-- storage/http.go | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/engine/backend/gifsicle.go b/engine/backend/gifsicle.go index 017be74f..3fba6238 100644 --- a/engine/backend/gifsicle.go +++ b/engine/backend/gifsicle.go @@ -31,7 +31,7 @@ func (b *Gifsicle) Resize(ctx context.Context, imgfile *image.ImageFile, opts *O return imgfile.Source, nil } - cmd := exec.Command(b.Path, + cmd := exec.CommandContext(ctx, b.Path, "--resize", fmt.Sprintf("%dx%d", opts.Width, opts.Height), ) cmd.Stdin = bytes.NewReader(imgfile.Source) diff --git a/image/factory.go b/image/factory.go index 738d766c..8b13d8b2 100644 --- a/image/factory.go +++ b/image/factory.go @@ -12,10 +12,10 @@ import ( ) // FromURL retrieves an ImageFile from an url -func FromURL(u *url.URL, userAgent string) (*ImageFile, error) { +func FromURL(ctx context.Context, u *url.URL, userAgent string) (*ImageFile, error) { storage := storagepkg.NewHTTPStorage(nil, http.NewClient(http.WithUserAgent(userAgent))) - content, err := storage.OpenFromURL(u) + content, err := storage.OpenFromURL(ctx, u) if err != nil { return nil, err } diff --git a/storage/http.go b/storage/http.go index 4f367dfa..fcc0ba1f 100644 --- a/storage/http.go +++ b/storage/http.go @@ -44,12 +44,12 @@ func (s *HTTPStorage) Open(ctx context.Context, filepath string) (io.ReadCloser, return nil, err } - return s.OpenFromURL(u) + return s.OpenFromURL(ctx, u) } // OpenFromURL retrieves bytes from an url -func (s *HTTPStorage) OpenFromURL(u *url.URL) (io.ReadCloser, error) { - req, err := http.NewRequestWithContext(context.Background(), "GET", u.String(), nil) +func (s *HTTPStorage) OpenFromURL(ctx context.Context, u *url.URL) (io.ReadCloser, error) { + req, err := http.NewRequestWithContext(ctx, "GET", u.String(), nil) if err != nil { return nil, err }