Skip to content

Commit

Permalink
chore: adjusting on error return
Browse files Browse the repository at this point in the history
  • Loading branch information
maxwelbm committed May 21, 2024
1 parent a95d7f2 commit 33d033a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
10 changes: 9 additions & 1 deletion pkg/api/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,17 @@ func (c *Client) Upload(ctx context.Context, fileOps *contracts.FileOps, conf *c
req := c.apiClient.StorageAPI.StorageApiBucketsObjectsCreate(ctx, conf.Bucket, file).Body(fileOps.FileContent).ContentType(fileOps.MimeType)
_, httpResp, err := req.Execute()
if err != nil {
logger.Debug("Error while uploading file <"+fileOps.Path+"> to storage api", zap.Error(err))
if httpResp != nil {
logger.Debug("Error while uploading file <"+fileOps.Path+"> to storage api", zap.Error(err))
err := utils.LogAndRewindBody(httpResp)
if err != nil {
return err
}
return utils.ErrorPerStatusCode(httpResp, err)
}
return utils.ErrorPerStatusCode(httpResp, err)
}

return nil
}

Expand Down
12 changes: 6 additions & 6 deletions pkg/cmd/deploy/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ func worker(jobs <-chan contracts.FileOps, results chan<- error, currentFile *in
if err != nil {
continue
}
results <- nil
atomic.AddInt64(currentFile, 1)
return
break
}

logger.Debug("There have been 5 retries already, quitting upload")
results <- err
return
if Retries >= 5 {
logger.Debug("There have been 5 retries already, quitting upload")
results <- err
return
}
}

atomic.AddInt64(currentFile, 1)
Expand Down

0 comments on commit 33d033a

Please sign in to comment.