Skip to content

Commit

Permalink
putObject: Streaming uploads with size -1 should avoid fetching previ…
Browse files Browse the repository at this point in the history
…ous partsInfo.

size == -1 should be treated specially for putObjectStream() and avoid fetching
partsInfo for previously uploaded parts since '-1' has no guarantee that the
data has no changed. Let the client upload again and not resume for unknown sizes.

Fixes - minio/mc#1819
  • Loading branch information
harshavardhana committed Sep 3, 2016
1 parent 583c261 commit a8b4f80
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions api-put-object-multipart.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,9 @@ func (c Client) putObjectMultipartStream(bucketName, objectName string, reader i
}

// If This session is a continuation of a previous session fetch all
// previously uploaded parts info.
if !isNew {
// previously uploaded parts info and as a special case only fetch partsInfo
// for only known upload size.
if !isNew && size > -1 {
// Fetch previously uploaded parts and maximum part size.
partsInfo, err = c.listObjectParts(bucketName, objectName, uploadID)
if err != nil {
Expand Down Expand Up @@ -190,7 +191,12 @@ func (c Client) putObjectMultipartStream(bucketName, objectName string, reader i
for i := 1; i <= totalPartsCount; i++ {
part, ok := partsInfo[i]
if !ok {
return 0, ErrInvalidArgument(fmt.Sprintf("Missing part number %d", i))
// Error our only if we know exactly the right amount of part sizes.
if size > -1 {
return 0, ErrInvalidArgument(fmt.Sprintf("Missing part number %d", i))
}
// Breakout an finish the upload if size is -1.
break
}
complMultipartUpload.Parts = append(complMultipartUpload.Parts, completePart{
ETag: part.ETag,
Expand Down

0 comments on commit a8b4f80

Please sign in to comment.