Fix missing CompleteMultipartUpload Etag. (#3227)

Fixes #3224
master
Harshavardhana 8 years ago committed by GitHub
parent 2f373684f5
commit 51d1e6f75b
  1. 2
      cmd/fs-v1-multipart.go
  2. 2
      cmd/object-api-multipart_test.go
  3. 4
      cmd/object-handlers.go
  4. 2
      cmd/object-handlers_test.go
  5. 2
      cmd/object-utils.go
  6. 2
      cmd/object-utils_test.go
  7. 9
      cmd/server_test.go
  8. 2
      cmd/xl-v1-multipart.go

@ -660,7 +660,7 @@ func (fs fsObjects) CompleteMultipartUpload(bucket string, object string, upload
defer appendPathLock.Unlock()
// Calculate s3 compatible md5sum for complete multipart.
s3MD5, err := getCompleteMultipartMD5(parts...)
s3MD5, err := getCompleteMultipartMD5(parts)
if err != nil {
return "", err
}

@ -1864,7 +1864,7 @@ func testObjectCompleteMultipartUpload(obj ObjectLayer, instanceType string, t T
},
},
}
s3MD5, err := getCompleteMultipartMD5(inputParts[3].parts...)
s3MD5, err := getCompleteMultipartMD5(inputParts[3].parts)
if err != nil {
t.Fatalf("Obtaining S3MD5 failed")
}

@ -877,7 +877,6 @@ func (api objectAPIHandlers) CompleteMultipartUploadHandler(w http.ResponseWrite
}
md5Sum, err = objectAPI.CompleteMultipartUpload(bucket, object, uploadID, completeParts)
if err != nil {
err = errorCause(err)
errorIf(err, "Unable to complete multipart upload.")
@ -903,6 +902,9 @@ func (api objectAPIHandlers) CompleteMultipartUploadHandler(w http.ResponseWrite
return
}
// Set etag.
w.Header().Set("ETag", "\""+md5Sum+"\"")
// Write success response.
w.Write(encodedSuccessResponse)
w.(http.Flusher).Flush()

@ -1507,7 +1507,7 @@ func testAPICompleteMultipartHandler(obj ObjectLayer, instanceType, bucketName s
}
// on successful complete multipart operation the s3MD5 for the parts uploaded will be returned.
s3MD5, err := getCompleteMultipartMD5(inputParts[3].parts...)
s3MD5, err := getCompleteMultipartMD5(inputParts[3].parts)
if err != nil {
t.Fatalf("Obtaining S3MD5 failed")
}

@ -141,7 +141,7 @@ func getUUID() (uuidStr string) {
}
// Create an s3 compatible MD5sum for complete multipart transaction.
func getCompleteMultipartMD5(parts ...completePart) (string, error) {
func getCompleteMultipartMD5(parts []completePart) (string, error) {
var finalMD5Bytes []byte
for _, part := range parts {
md5Bytes, err := hex.DecodeString(part.ETag)

@ -158,7 +158,7 @@ func TestGetCompleteMultipartMD5(t *testing.T) {
}
for i, test := range testCases {
result, err := getCompleteMultipartMD5(test.parts...)
result, err := getCompleteMultipartMD5(test.parts)
if result != test.expectedResult {
t.Fatalf("test %d failed: expected: result=%v, got=%v", i+1, test.expectedResult, result)
}

@ -2503,5 +2503,12 @@ func (s *TestSuiteCommon) TestObjectMultipart(c *C) {
c.Assert(err, IsNil)
// verify whether complete multipart was successful.
c.Assert(response.StatusCode, Equals, http.StatusOK)
var parts []completePart
for _, part := range completeUploads.Parts {
part.ETag = strings.Trim(part.ETag, "\"")
parts = append(parts, part)
}
etag, err := getCompleteMultipartMD5(parts)
c.Assert(err, IsNil)
c.Assert(strings.Trim(response.Header.Get("Etag"), "\""), Equals, etag)
}

@ -664,7 +664,7 @@ func (xl xlObjects) CompleteMultipartUpload(bucket string, object string, upload
return "", traceError(InvalidUploadID{UploadID: uploadID})
}
// Calculate s3 compatible md5sum for complete multipart.
s3MD5, err := getCompleteMultipartMD5(parts...)
s3MD5, err := getCompleteMultipartMD5(parts)
if err != nil {
return "", err
}

Loading…
Cancel
Save