|
@ -134,6 +134,9 @@ func (s3a *S3ApiServer) listFilerEntries(bucket string, originalPrefix string, m |
|
|
} |
|
|
} |
|
|
bucketPrefix := fmt.Sprintf("%s/%s/", s3a.option.BucketsPath, bucket) |
|
|
bucketPrefix := fmt.Sprintf("%s/%s/", s3a.option.BucketsPath, bucket) |
|
|
reqDir = fmt.Sprintf("%s%s", bucketPrefix, reqDir) |
|
|
reqDir = fmt.Sprintf("%s%s", bucketPrefix, reqDir) |
|
|
|
|
|
if prefix == "" && strings.HasSuffix(reqDir, "/") { |
|
|
|
|
|
reqDir, prefix = filepath.Split(reqDir[:len(reqDir)-1]) |
|
|
|
|
|
} |
|
|
if strings.HasSuffix(reqDir, "/") { |
|
|
if strings.HasSuffix(reqDir, "/") { |
|
|
// remove trailing "/"
|
|
|
// remove trailing "/"
|
|
|
reqDir = reqDir[:len(reqDir)-1] |
|
|
reqDir = reqDir[:len(reqDir)-1] |
|
@ -149,19 +152,21 @@ func (s3a *S3ApiServer) listFilerEntries(bucket string, originalPrefix string, m |
|
|
err = s3a.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error { |
|
|
err = s3a.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error { |
|
|
|
|
|
|
|
|
_, isTruncated, nextMarker, doErr = s3a.doListFilerEntries(client, reqDir, prefix, maxKeys, marker, delimiter, func(dir string, entry *filer_pb.Entry) { |
|
|
_, isTruncated, nextMarker, doErr = s3a.doListFilerEntries(client, reqDir, prefix, maxKeys, marker, delimiter, func(dir string, entry *filer_pb.Entry) { |
|
|
if entry.IsDirectory { |
|
|
|
|
|
if delimiter == "/" { |
|
|
|
|
|
commonPrefixes = append(commonPrefixes, PrefixEntry{ |
|
|
|
|
|
Prefix: fmt.Sprintf("%s/%s/", dir, entry.Name)[len(bucketPrefix):], |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if entry.IsDirectory && delimiter == "/" { |
|
|
|
|
|
commonPrefixes = append(commonPrefixes, PrefixEntry{ |
|
|
|
|
|
Prefix: fmt.Sprintf("%s/%s/", dir, entry.Name)[len(bucketPrefix):], |
|
|
|
|
|
}) |
|
|
} else { |
|
|
} else { |
|
|
storageClass := "STANDARD" |
|
|
storageClass := "STANDARD" |
|
|
if v, ok := entry.Extended[xhttp.AmzStorageClass]; ok { |
|
|
if v, ok := entry.Extended[xhttp.AmzStorageClass]; ok { |
|
|
storageClass = string(v) |
|
|
storageClass = string(v) |
|
|
} |
|
|
} |
|
|
|
|
|
entryName := entry.Name |
|
|
|
|
|
if entry.IsDirectory { |
|
|
|
|
|
entryName += "/" |
|
|
|
|
|
} |
|
|
contents = append(contents, ListEntry{ |
|
|
contents = append(contents, ListEntry{ |
|
|
Key: fmt.Sprintf("%s/%s", dir, entry.Name)[len(bucketPrefix):], |
|
|
|
|
|
|
|
|
Key: fmt.Sprintf("%s/%s", dir, entryName)[len(bucketPrefix):], |
|
|
LastModified: time.Unix(entry.Attributes.Mtime, 0).UTC(), |
|
|
LastModified: time.Unix(entry.Attributes.Mtime, 0).UTC(), |
|
|
ETag: "\"" + filer.ETag(entry) + "\"", |
|
|
ETag: "\"" + filer.ETag(entry) + "\"", |
|
|
Size: int64(filer.FileSize(entry)), |
|
|
Size: int64(filer.FileSize(entry)), |
|
@ -289,10 +294,8 @@ func (s3a *S3ApiServer) doListFilerEntries(client filer_pb.SeaweedFilerClient, d |
|
|
glog.Errorf("check empty folder %s: %v", dir, err) |
|
|
glog.Errorf("check empty folder %s: %v", dir, err) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
if !isEmpty { |
|
|
|
|
|
eachEntryFn(dir, entry) |
|
|
|
|
|
counter++ |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
eachEntryFn(dir, entry) |
|
|
|
|
|
counter++ |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} else { |
|
|
} else { |
|
|