Skip to content

Commit

Permalink
made linter happy
Browse files Browse the repository at this point in the history
  • Loading branch information
smaant committed Dec 30, 2019
1 parent 63166bd commit 52e3de4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
9 changes: 4 additions & 5 deletions backend/app/rest/proxy/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,8 @@ func (p Image) Handler(w http.ResponseWriter, r *http.Request) {
return
}
if p.CacheExternal {
imgReader, _, err = p.ImageService.Load(imgID)
if err != nil {
// Image hasn't been cached yet
}
// ignorring return error because it means that image hasn't been just cached yet
imgReader, _, _ = p.ImageService.Load(imgID)
}
if imgReader == nil {
imgReader, err = p.downloadImage(context.Background(), imgURL)
Expand Down Expand Up @@ -174,7 +172,8 @@ func (p Image) downloadImage(ctx context.Context, imgURL string) (io.ReadCloser,
timeout = p.Timeout
}

ctx, _ = context.WithTimeout(ctx, timeout)
ctx, cancel := context.WithTimeout(ctx, timeout)
defer cancel()

client := http.Client{Timeout: 30 * time.Second}
var resp *http.Response
Expand Down
2 changes: 1 addition & 1 deletion backend/app/rest/proxy/image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func TestImage_Routes_CachingImage(t *testing.T) {
encodedImgURL := base64.URLEncoding.EncodeToString([]byte(imgURL))

imageStore.On("Load", mock.Anything).Once().Return(nil, int64(0), nil)
imageStore.On("SaveWithID", mock.Anything, mock.Anything).Once().Run(func(args mock.Arguments) { ioutil.ReadAll(args.Get(1).(io.Reader)) }).Return("", nil)
imageStore.On("SaveWithID", mock.Anything, mock.Anything).Once().Run(func(args mock.Arguments) { _, _ = ioutil.ReadAll(args.Get(1).(io.Reader)) }).Return("", nil)
imageStore.On("Commit", mock.Anything).Once().Return(nil)

resp, err := http.Get(ts.URL + "/?src=" + encodedImgURL)
Expand Down

0 comments on commit 52e3de4

Please sign in to comment.