Skip to content

Commit

Permalink
Merge pull request #15 from sapcc/rate_limit
Browse files Browse the repository at this point in the history
Don't delete failed upload caused by rate limit
  • Loading branch information
majewsky authored Nov 13, 2017
2 parents 11dcb85 + 733335f commit e7aecae
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/objects/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,14 @@ func (f File) uploadNormalObject(body io.Reader, sourceState FileState, hdr swif

util.Log(util.LogError, "PUT %s/%s failed: %s", containerName, objectName, err.Error())

if serr, ok := err.(*swift.Error); ok {
//upload failed due to rate limit, object is definitely not uploaded
//prevent additional rate limit caused by an unnecessary delete request
if serr.StatusCode == 498 {
return false
}
}

//delete potentially incomplete upload
err = f.Job.Target.Connection.ObjectDelete(containerName, objectName)
if err != nil {
Expand Down

0 comments on commit e7aecae

Please sign in to comment.