s3: Don't set NextMarker when listing is not truncated (#7012)

Setting NextMarker when IsTruncated is not set seems to be confusing
AWS C++ SDK, this commit will avoid setting any string in NextMarker.
master
Anis Elleuch 6 years ago committed by kannappanr
parent def04f01cf
commit 632022971b
  1. 10
      cmd/fs-v1.go
  2. 8
      cmd/object-api-listobjects_test.go
  3. 11
      cmd/xl-v1-list-objects.go

@ -1212,9 +1212,8 @@ func (fs *FSObjects) ListObjects(ctx context.Context, bucket, prefix, marker, de
fs.listPool.Set(params, walkResultCh, endWalkCh) fs.listPool.Set(params, walkResultCh, endWalkCh)
} }
result := ListObjectsInfo{IsTruncated: !eof} result := ListObjectsInfo{}
for _, objInfo := range objInfos { for _, objInfo := range objInfos {
result.NextMarker = objInfo.Name
if objInfo.IsDir && delimiter == slashSeparator { if objInfo.IsDir && delimiter == slashSeparator {
result.Prefixes = append(result.Prefixes, objInfo.Name) result.Prefixes = append(result.Prefixes, objInfo.Name)
continue continue
@ -1222,6 +1221,13 @@ func (fs *FSObjects) ListObjects(ctx context.Context, bucket, prefix, marker, de
result.Objects = append(result.Objects, objInfo) result.Objects = append(result.Objects, objInfo)
} }
if !eof {
result.IsTruncated = true
if len(objInfos) > 0 {
result.NextMarker = objInfos[len(objInfos)-1].Name
}
}
// Success. // Success.
return result, nil return result, nil
} }

@ -574,6 +574,14 @@ func testListObjects(obj ObjectLayer, instanceType string, t TestErrHandler) {
t.Errorf("Test %d: %s: Expected IsTruncated flag to be %v, but instead found it to be %v", i+1, instanceType, testCase.result.IsTruncated, result.IsTruncated) t.Errorf("Test %d: %s: Expected IsTruncated flag to be %v, but instead found it to be %v", i+1, instanceType, testCase.result.IsTruncated, result.IsTruncated)
} }
if testCase.result.IsTruncated && result.NextMarker == "" {
t.Errorf("Test %d: %s: Expected NextContinuationToken to contain a string since listing is truncated, but instead found it to be empty", i+1, instanceType)
}
if !testCase.result.IsTruncated && result.NextMarker != "" {
t.Errorf("Test %d: %s: Expected NextContinuationToken to be empty since listing is not truncated, but instead found `%v`", i+1, instanceType, result.NextMarker)
}
} }
// Take ListObject treeWalk go-routine to completion, if available in the treewalk pool. // Take ListObject treeWalk go-routine to completion, if available in the treewalk pool.
if result.IsTruncated { if result.IsTruncated {

@ -130,15 +130,22 @@ func (xl xlObjects) listObjects(ctx context.Context, bucket, prefix, marker, del
xl.listPool.Set(params, walkResultCh, endWalkCh) xl.listPool.Set(params, walkResultCh, endWalkCh)
} }
result := ListObjectsInfo{IsTruncated: !eof} result := ListObjectsInfo{}
for _, objInfo := range objInfos { for _, objInfo := range objInfos {
result.NextMarker = objInfo.Name
if objInfo.IsDir && delimiter == slashSeparator { if objInfo.IsDir && delimiter == slashSeparator {
result.Prefixes = append(result.Prefixes, objInfo.Name) result.Prefixes = append(result.Prefixes, objInfo.Name)
continue continue
} }
result.Objects = append(result.Objects, objInfo) result.Objects = append(result.Objects, objInfo)
} }
if !eof {
result.IsTruncated = true
if len(objInfos) > 0 {
result.NextMarker = objInfos[len(objInfos)-1].Name
}
}
return result, nil return result, nil
} }

Loading…
Cancel
Save