Fix issue with AbortMultipartUpload, closes #4322

This commit is contained in:
Remco Verhoef 2017-05-11 14:21:56 -07:00 committed by Harshavardhana
parent bfff251e2a
commit 3b9d313c87

View File

@ -779,26 +779,30 @@ func (l *gcsGateway) ListObjectParts(bucket string, key string, uploadID string,
// AbortMultipartUpload aborts a ongoing multipart upload
func (l *gcsGateway) AbortMultipartUpload(bucket string, key string, uploadID string) error {
prefix := fmt.Sprintf("%s/multipart-%s-%s", ZZZZMinioPrefix, key, uploadID)
delimiter := "/"
// delete part zero, ignoring errors here, we want to clean up all remains
_ = l.client.Bucket(bucket).Object(toGCSMultipartKey(key, uploadID, 0)).Delete(l.ctx)
delimiter := "/"
prefix := fmt.Sprintf("%s/multipart-%s-%s", ZZZZMinioPrefix, key, uploadID)
// iterate through all parts and delete them
it := l.client.Bucket(bucket).Objects(l.ctx, &storage.Query{Delimiter: delimiter, Prefix: prefix, Versions: false})
it.PageInfo().Token = toGCSPageToken(toGCSMultipartKey(key, uploadID, 0))
for {
attrs, err := it.Next()
if err == iterator.Done {
break
} else if err != nil {
return gcsToObjectError(traceError(err), bucket, prefix)
return gcsToObjectError(traceError(err), bucket, key)
}
// on error continue deleting other parts
l.client.Bucket(bucket).Object(attrs.Name).Delete(l.ctx)
}
// delete part zero, ignoring errors here, we want to clean up all remains
_ = l.client.Bucket(bucket).Object(toGCSMultipartKey(key, uploadID, 0)).Delete(l.ctx)
return nil
}