aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLHHDZ <changlin.shi@ly.com>2023-02-22 15:08:52 +0800
committerGitHub <noreply@github.com>2023-02-21 23:08:52 -0800
commitdb5515eadac59ecaffc08e60cfea594041955338 (patch)
tree7cb9736c80dded6f586be34f3f070ebe114f06ea
parentef2f741823bdb8cc9ebefb45183612a9cf630d5e (diff)
downloadseaweedfs-db5515eadac59ecaffc08e60cfea594041955338.tar.xz
seaweedfs-db5515eadac59ecaffc08e60cfea594041955338.zip
Fix s3api_object_list_handlers returning contents less than the specified limit when more data actually exists (#4240)
Fix when the stored data is actually enough but s3api_object_list_handlers returns less than the specified limit Signed-off-by: changlin.shi <changlin.shi@ly.com>
-rw-r--r--weed/s3api/s3api_objects_list_handlers.go86
1 files changed, 47 insertions, 39 deletions
diff --git a/weed/s3api/s3api_objects_list_handlers.go b/weed/s3api/s3api_objects_list_handlers.go
index c1dbafefe..b9eddd921 100644
--- a/weed/s3api/s3api_objects_list_handlers.go
+++ b/weed/s3api/s3api_objects_list_handlers.go
@@ -146,57 +146,65 @@ func (s3a *S3ApiServer) listFilerEntries(bucket string, originalPrefix string, m
// check filer
err = s3a.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {
-
- nextMarker, doErr = s3a.doListFilerEntries(client, reqDir, prefix, cursor, marker, delimiter, false, func(dir string, entry *filer_pb.Entry) {
- if entry.IsDirectory {
- // https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjectsV2.html
- if delimiter == "/" { // A response can contain CommonPrefixes only if you specify a delimiter.
- commonPrefixes = append(commonPrefixes, PrefixEntry{
- Prefix: fmt.Sprintf("%s/%s/", dir, entry.Name)[len(bucketPrefix):],
- })
- //All of the keys (up to 1,000) rolled up into a common prefix count as a single return when calculating the number of returns.
- cursor.maxKeys--
- } else if entry.IsDirectoryKeyObject() {
+ for {
+ empty := true
+ nextMarker, doErr = s3a.doListFilerEntries(client, reqDir, prefix, cursor, marker, delimiter, false, func(dir string, entry *filer_pb.Entry) {
+ empty = false
+ if entry.IsDirectory {
+ // https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjectsV2.html
+ if delimiter == "/" { // A response can contain CommonPrefixes only if you specify a delimiter.
+ commonPrefixes = append(commonPrefixes, PrefixEntry{
+ Prefix: fmt.Sprintf("%s/%s/", dir, entry.Name)[len(bucketPrefix):],
+ })
+ //All of the keys (up to 1,000) rolled up into a common prefix count as a single return when calculating the number of returns.
+ cursor.maxKeys--
+ } else if entry.IsDirectoryKeyObject() {
+ contents = append(contents, ListEntry{
+ Key: fmt.Sprintf("%s/%s/", dir, entry.Name)[len(bucketPrefix):],
+ LastModified: time.Unix(entry.Attributes.Mtime, 0).UTC(),
+ ETag: "\"" + filer.ETag(entry) + "\"",
+ Owner: CanonicalUser{
+ ID: fmt.Sprintf("%x", entry.Attributes.Uid),
+ DisplayName: entry.Attributes.UserName,
+ },
+ StorageClass: "STANDARD",
+ })
+ cursor.maxKeys--
+ }
+ } else {
+ storageClass := "STANDARD"
+ if v, ok := entry.Extended[s3_constants.AmzStorageClass]; ok {
+ storageClass = string(v)
+ }
contents = append(contents, ListEntry{
- Key: fmt.Sprintf("%s/%s/", dir, entry.Name)[len(bucketPrefix):],
+ Key: fmt.Sprintf("%s/%s", dir, entry.Name)[len(bucketPrefix):],
LastModified: time.Unix(entry.Attributes.Mtime, 0).UTC(),
ETag: "\"" + filer.ETag(entry) + "\"",
+ Size: int64(filer.FileSize(entry)),
Owner: CanonicalUser{
ID: fmt.Sprintf("%x", entry.Attributes.Uid),
DisplayName: entry.Attributes.UserName,
},
- StorageClass: "STANDARD",
+ StorageClass: StorageClass(storageClass),
})
cursor.maxKeys--
}
- } else {
- storageClass := "STANDARD"
- if v, ok := entry.Extended[s3_constants.AmzStorageClass]; ok {
- storageClass = string(v)
- }
- contents = append(contents, ListEntry{
- Key: fmt.Sprintf("%s/%s", dir, entry.Name)[len(bucketPrefix):],
- LastModified: time.Unix(entry.Attributes.Mtime, 0).UTC(),
- ETag: "\"" + filer.ETag(entry) + "\"",
- Size: int64(filer.FileSize(entry)),
- Owner: CanonicalUser{
- ID: fmt.Sprintf("%x", entry.Attributes.Uid),
- DisplayName: entry.Attributes.UserName,
- },
- StorageClass: StorageClass(storageClass),
- })
- cursor.maxKeys--
+ })
+ if doErr != nil {
+ return doErr
}
- })
- if doErr != nil {
- return doErr
- }
- if !cursor.isTruncated {
- nextMarker = ""
- } else {
- if requestDir != "" {
- nextMarker = requestDir + "/" + nextMarker
+ if cursor.isTruncated {
+ if requestDir != "" {
+ nextMarker = requestDir + "/" + nextMarker
+ }
+ break
+ } else if empty {
+ nextMarker = ""
+ break
+ } else {
+ // start next loop
+ marker = nextMarker
}
}