Skip to content

Commit

Permalink
add missing context
Browse files Browse the repository at this point in the history
  • Loading branch information
Houtmann committed Sep 18, 2023
1 parent 330214e commit 7baa97a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion engine/backend/gifsicle.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions image/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
6 changes: 3 additions & 3 deletions storage/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 7baa97a

Please sign in to comment.