mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-05-04 13:37:49 +08:00
fix s3api: delimeter properly takes prefixes into account (#5411)
This commit is contained in:
parent
a5582cc921
commit
61f4e40ad9
@ -167,12 +167,16 @@ func (s3a *S3ApiServer) listFilerEntries(bucket string, originalPrefix string, m
|
|||||||
if delimiter != "" {
|
if delimiter != "" {
|
||||||
// keys that contain the same string between the prefix and the first occurrence of the delimiter are grouped together as a commonPrefix.
|
// keys that contain the same string between the prefix and the first occurrence of the delimiter are grouped together as a commonPrefix.
|
||||||
// extract the string between the prefix and the delimiter and add it to the commonPrefixes if it's unique.
|
// extract the string between the prefix and the delimiter and add it to the commonPrefixes if it's unique.
|
||||||
fullPath := fmt.Sprintf("%s/%s", dir, entry.Name)[len(bucketPrefix):]
|
undelimitedPath := fmt.Sprintf("%s/%s", dir, entry.Name)[len(bucketPrefix):]
|
||||||
delimitedPath := strings.SplitN(fullPath, delimiter, 2)
|
|
||||||
if len(delimitedPath) == 2 {
|
|
||||||
|
|
||||||
// S3 clients expect the delimited prefix to contain the delimiter.
|
// take into account a prefix if supplied while delimiting.
|
||||||
delimitedPrefix := delimitedPath[0] + delimiter
|
undelimitedPath = strings.TrimPrefix(undelimitedPath, originalPrefix)
|
||||||
|
|
||||||
|
delimitedPath := strings.SplitN(undelimitedPath, delimiter, 2)
|
||||||
|
|
||||||
|
if len(delimitedPath) == 2 {
|
||||||
|
// S3 clients expect the delimited prefix to contain the delimiter and prefix.
|
||||||
|
delimitedPrefix := originalPrefix + delimitedPath[0] + delimiter
|
||||||
|
|
||||||
for i := range commonPrefixes {
|
for i := range commonPrefixes {
|
||||||
if commonPrefixes[i].Prefix == delimitedPrefix {
|
if commonPrefixes[i].Prefix == delimitedPrefix {
|
||||||
|
Loading…
Reference in New Issue
Block a user