mirror of
https://github.com/minio/minio.git
synced 2025-11-09 05:34:56 -05:00
fix: honor delimiter as per AWS S3 spec (#10823)
This commit is contained in:
@@ -301,6 +301,20 @@ func (m *metaCacheEntriesSorted) fileInfoVersions(bucket, prefix, delimiter, aft
|
||||
prevPrefix := ""
|
||||
for _, entry := range m.o {
|
||||
if entry.isObject() {
|
||||
if delimiter != "" {
|
||||
idx := strings.Index(strings.TrimPrefix(entry.name, prefix), delimiter)
|
||||
if idx >= 0 {
|
||||
idx = len(prefix) + idx + len(delimiter)
|
||||
currPrefix := entry.name[:idx]
|
||||
if currPrefix == prevPrefix {
|
||||
continue
|
||||
}
|
||||
prevPrefix = currPrefix
|
||||
commonPrefixes = append(commonPrefixes, currPrefix)
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
fiv, err := entry.fileInfoVersions(bucket)
|
||||
if afterV != "" {
|
||||
// Forward first entry to specified version
|
||||
@@ -314,6 +328,7 @@ func (m *metaCacheEntriesSorted) fileInfoVersions(bucket, prefix, delimiter, aft
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
if entry.isDir() {
|
||||
if delimiter == "" {
|
||||
continue
|
||||
@@ -343,6 +358,20 @@ func (m *metaCacheEntriesSorted) fileInfos(bucket, prefix, delimiter string) (ob
|
||||
prevPrefix := ""
|
||||
for _, entry := range m.o {
|
||||
if entry.isObject() {
|
||||
if delimiter != "" {
|
||||
idx := strings.Index(strings.TrimPrefix(entry.name, prefix), delimiter)
|
||||
if idx >= 0 {
|
||||
idx = len(prefix) + idx + len(delimiter)
|
||||
currPrefix := entry.name[:idx]
|
||||
if currPrefix == prevPrefix {
|
||||
continue
|
||||
}
|
||||
prevPrefix = currPrefix
|
||||
commonPrefixes = append(commonPrefixes, currPrefix)
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
fi, err := entry.fileInfo(bucket)
|
||||
if err == nil {
|
||||
objects = append(objects, fi.ToObjectInfo(bucket, entry.name))
|
||||
|
||||
Reference in New Issue
Block a user