Skip to content

Commit

Permalink
make sure to ignore non-existent versions (#1419)
Browse files Browse the repository at this point in the history
  • Loading branch information
harshavardhana authored Nov 28, 2020
1 parent 339113f commit 3283e71
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
22 changes: 20 additions & 2 deletions api-remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,14 @@ func processRemoveMultiObjectsResponse(body io.Reader, objects []ObjectInfo, err

// Fill deletion that returned an error.
for _, obj := range rmResult.UnDeletedObjects {
// Version does not exist is not an error ignore and continue.
switch obj.Code {
case "InvalidArgument", "NoSuchVersion":
continue
}
errorCh <- RemoveObjectError{
ObjectName: obj.Key,
VersionID: obj.VersionID,
Err: ErrorResponse{
Code: obj.Code,
Message: obj.Message,
Expand Down Expand Up @@ -254,9 +260,21 @@ func (c Client) removeObjects(ctx context.Context, bucketName string, objectsCh
for object := range objectsCh {
if hasInvalidXMLChar(object.Key) {
// Use single DELETE so the object name will be in the request URL instead of the multi-delete XML document.
err := c.removeObject(ctx, bucketName, object.Key, RemoveObjectOptions{GovernanceBypass: opts.GovernanceBypass})
err := c.removeObject(ctx, bucketName, object.Key, RemoveObjectOptions{
VersionID: object.VersionID,
GovernanceBypass: opts.GovernanceBypass,
})
if err != nil {
errorCh <- RemoveObjectError{ObjectName: object.Key, Err: err}
// Version does not exist is not an error ignore and continue.
switch ToErrorResponse(err).Code {
case "InvalidArgument", "NoSuchVersion":
continue
}
errorCh <- RemoveObjectError{
ObjectName: object.Key,
VersionID: object.VersionID,
Err: err,
}
}
continue
}
Expand Down
7 changes: 4 additions & 3 deletions api-s3-datatypes.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,9 +340,10 @@ type deletedObject struct {

// nonDeletedObject container for Error element (failed deletion) in MultiObjects Delete XML response
type nonDeletedObject struct {
Key string
Code string
Message string
Key string
Code string
Message string
VersionID string `xml:"VersionId"`
}

// deletedMultiObjects container for MultiObjects Delete XML request
Expand Down

0 comments on commit 3283e71

Please sign in to comment.