rename completeMultipartMD5() into getCompleteMultipartMD5(). (#3051)

master
Bala FA 8 years ago committed by Harshavardhana
parent 7fc598b73f
commit 36639b65a9
  1. 2
      cmd/fs-v1-multipart.go
  2. 2
      cmd/object-api-multipart_test.go
  3. 2
      cmd/object-handlers_test.go
  4. 2
      cmd/object-utils.go
  5. 32
      cmd/object-utils_test.go
  6. 2
      cmd/xl-v1-multipart.go

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

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

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

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

@ -136,3 +136,35 @@ func TestLimitReader(t *testing.T) {
} }
} }
} }
// Tests getCompleteMultipartMD5
func TestGetCompleteMultipartMD5(t *testing.T) {
testCases := []struct {
parts []completePart
expectedResult string
expectedErr string
}{
// Wrong MD5 hash string
{[]completePart{{ETag: "wrong-md5-hash-string"}}, "", "encoding/hex: odd length hex string"},
// Single completePart with valid MD5 hash string.
{[]completePart{{ETag: "cf1f738a5924e645913c984e0fe3d708"}}, "10dc1617fbcf0bd0858048cb96e6bd77-1", ""},
// Multiple completePart with valid MD5 hash string.
{[]completePart{{ETag: "cf1f738a5924e645913c984e0fe3d708"}, {ETag: "9ccbc9a80eee7fb6fdd22441db2aedbd"}}, "0239a86b5266bb624f0ac60ba2aed6c8-2", ""},
}
for i, test := range testCases {
result, err := getCompleteMultipartMD5(test.parts...)
if result != test.expectedResult {
t.Fatalf("test %d failed: expected: result=%v, got=%v", i+1, test.expectedResult, result)
}
errString := ""
if err != nil {
errString = err.Error()
}
if errString != test.expectedErr {
t.Fatalf("test %d failed: expected: err=%v, got=%v", i+1, test.expectedErr, err)
}
}
}

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

Loading…
Cancel
Save