Fix ListObjectParts to list properly all parts - closes #4322

master
Remco Verhoef 8 years ago committed by Harshavardhana
parent 52122c0309
commit 9c50a9f567
  1. 4
      cmd/gateway-gcs.go
  2. 35
      cmd/gateway-gcs_test.go

@ -649,7 +649,7 @@ func fromGCSMultipartKey(s string) (key, uploadID string, partID int, err error)
key = unescape(parts[1]) key = unescape(parts[1])
uploadID = parts[3] uploadID = parts[2]
partID, err = strconv.Atoi(parts[3]) partID, err = strconv.Atoi(parts[3])
if err != nil { if err != nil {
@ -728,7 +728,7 @@ func (l *gcsGateway) ListObjectParts(bucket string, key string, uploadID string,
isTruncated := false isTruncated := false
it.PageInfo().Token = toGCSMultipartKey(key, uploadID, partNumberMarker) it.PageInfo().Token = toGCSPageToken(toGCSMultipartKey(key, uploadID, partNumberMarker))
it.PageInfo().MaxSize = maxParts it.PageInfo().MaxSize = maxParts
nextPartnumberMarker := 0 nextPartnumberMarker := 0

@ -18,6 +18,41 @@ package cmd
import "testing" import "testing"
func TestEscape(t *testing.T) {
testCases := []struct {
Value string
EscapedValue string
}{
{
Value: "test-test",
EscapedValue: "test%2Dtest",
},
{
Value: "test/test",
EscapedValue: "test%2Ftest",
},
{
Value: "test%test",
EscapedValue: "test%25test",
},
{
Value: "%%%////+++",
EscapedValue: "%25%25%25%2F%2F%2F%2F+++",
},
}
for i, testCase := range testCases {
if escape(testCase.Value) != testCase.EscapedValue {
t.Errorf("Test %d: Expected %s, got %s", i+1, testCase.EscapedValue, escape(testCase.Value))
}
if unescape(testCase.EscapedValue) != testCase.Value {
t.Errorf("Test %d: Expected %s, got %s", i+1, testCase.Value, unescape(testCase.EscapedValue))
}
}
}
func TestToGCSPageToken(t *testing.T) { func TestToGCSPageToken(t *testing.T) {
testCases := []struct { testCases := []struct {
Name string Name string

Loading…
Cancel
Save