mirror of
https://github.com/pgsty/minio.git
synced 2026-07-24 06:26:17 +03:00
listing: Fix result when prefix is an object with a slash (#10267)
In a non recursive mode, issuing a list request where prefix is an existing object with a slash and delimiter is a slash will return entries in the object directory (data dir IDs) ``` $ aws s3api --profile minioadmin --endpoint-url http://localhost:9000 \ list-objects-v2 --bucket testbucket --prefix code_of_conduct.md/ --delimiter '/' { "CommonPrefixes": [ { "Prefix": "code_of_conduct.md/ec750fe0-ea7e-4b87-bbec-1e32407e5e47/" } ] } ``` This commit adds a fast exit track in Walk() in this specific case.
This commit is contained in:
@@ -949,6 +949,14 @@ func (s *xlStorage) Walk(volume, dirPath, marker string, recursive bool, endWalk
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Fast exit track to check if we are listing an object with
|
||||
// a trailing slash, this will avoid to list the object content.
|
||||
if HasSuffix(dirPath, SlashSeparator) {
|
||||
if st, err := os.Stat(pathJoin(volumeDir, dirPath, xlStorageFormatFile)); err == nil && st.Mode().IsRegular() {
|
||||
return nil, errFileNotFound
|
||||
}
|
||||
}
|
||||
|
||||
// buffer channel matches the S3 ListObjects implementation
|
||||
ch = make(chan FileInfo, maxObjectList)
|
||||
go func() {
|
||||
|
||||
Reference in New Issue
Block a user