mirror of
https://github.com/minio/minio.git
synced 2025-01-23 12:43:16 -05:00
fix: listing for directory object when delimiter is present (#11463)
When you have heirarchy of prefixes with directory objects our current master would list directory objects as prefixes when delimiter is present, this is inconsistent with AWS S3 ``` aws s3api list-objects --endpoint-url http://localhost:9000 \ --profile minio --bucket testbucket-v --prefix new/ --delimiter / { "CommonPrefixes": [ { "Prefix": "new/" }, { "Prefix": "new/new/" } ] } ``` Instead this PR fixes this to behave like AWS S3 ``` aws s3api list-objects --endpoint-url http://localhost:9000 \ --profile minio --bucket testbucket-v --prefix new/ --delimiter / { "Contents": [ { "Key": "new/", "LastModified": "2021-02-05T06:27:42.660Z", "ETag": "\"d41d8cd98f00b204e9800998ecf8427e\"", "Size": 0, "StorageClass": "STANDARD", "Owner": { "DisplayName": "", "ID": "02d6176db174dc93cb1b899f7c6078f08654445fe8cf1b6ce98d8855f66bdbf4" } } ], "CommonPrefixes": [ { "Prefix": "new/new/" } ] } ```
This commit is contained in:
parent
5fe4bb6b36
commit
1fdafaf72f
@ -782,7 +782,7 @@ func (z *erasureServerPools) ListObjectVersions(ctx context.Context, bucket, pre
|
|||||||
loi.IsTruncated = true
|
loi.IsTruncated = true
|
||||||
}
|
}
|
||||||
for _, obj := range objects {
|
for _, obj := range objects {
|
||||||
if obj.IsDir && delimiter != "" {
|
if obj.IsDir && obj.ModTime.IsZero() && delimiter != "" {
|
||||||
loi.Prefixes = append(loi.Prefixes, obj.Name)
|
loi.Prefixes = append(loi.Prefixes, obj.Name)
|
||||||
} else {
|
} else {
|
||||||
loi.Objects = append(loi.Objects, obj)
|
loi.Objects = append(loi.Objects, obj)
|
||||||
@ -821,7 +821,7 @@ func (z *erasureServerPools) ListObjects(ctx context.Context, bucket, prefix, ma
|
|||||||
loi.IsTruncated = true
|
loi.IsTruncated = true
|
||||||
}
|
}
|
||||||
for _, obj := range objects {
|
for _, obj := range objects {
|
||||||
if obj.IsDir && delimiter != "" {
|
if obj.IsDir && obj.ModTime.IsZero() && delimiter != "" {
|
||||||
loi.Prefixes = append(loi.Prefixes, obj.Name)
|
loi.Prefixes = append(loi.Prefixes, obj.Name)
|
||||||
} else {
|
} else {
|
||||||
loi.Objects = append(loi.Objects, obj)
|
loi.Objects = append(loi.Objects, obj)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user