refactor ObjectLayer PutObject and PutObjectPart (#4925)
This change refactor the ObjectLayer PutObject and PutObjectPart functions. Instead of passing an io.Reader and a size to PUT operations ObejectLayer expects an HashReader. A HashReader verifies the MD5 sum (and SHA256 sum if required) of the object. This change updates all all PutObject(Part) calls and removes unnecessary code in all ObjectLayer implementations. Fixes #4923
This commit is contained in:
committed by
Dee Koder
parent
f8024cadbb
commit
79ba4d3f33
@@ -17,8 +17,6 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@@ -131,34 +129,6 @@ func TestIsValidObjectName(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// Tests rangeReader.
|
||||
func TestRangeReader(t *testing.T) {
|
||||
testCases := []struct {
|
||||
data string
|
||||
minLen int64
|
||||
maxLen int64
|
||||
err error
|
||||
}{
|
||||
{"1234567890", 0, 15, nil},
|
||||
{"1234567890", 0, 10, nil},
|
||||
{"1234567890", 0, 5, toObjectErr(errDataTooLarge, "test", "test")},
|
||||
{"123", 5, 10, toObjectErr(errDataTooSmall, "test", "test")},
|
||||
{"123", 2, 10, nil},
|
||||
}
|
||||
|
||||
for i, test := range testCases {
|
||||
r := strings.NewReader(test.data)
|
||||
_, err := ioutil.ReadAll(&rangeReader{
|
||||
Reader: r,
|
||||
Min: test.minLen,
|
||||
Max: test.maxLen,
|
||||
})
|
||||
if toObjectErr(err, "test", "test") != test.err {
|
||||
t.Fatalf("test %d failed: expected %v, got %v", i+1, test.err, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Tests getCompleteMultipartMD5
|
||||
func TestGetCompleteMultipartMD5(t *testing.T) {
|
||||
testCases := []struct {
|
||||
|
||||
Reference in New Issue
Block a user