xl: Dedup common prefixes entries (#11426)
Since the support of empty directory __XLDIR__, the walk code in listing can return two duplicated entries, one as a real diretory, the second as the empty object with a trailing slash. The fix deduplicates entries in CommonPrefixes when that happens.
This commit is contained in:
parent
fed3bda697
commit
7f3f3ee1ee
|
@ -1319,11 +1319,15 @@ func (z *erasureServerSets) listObjectVersions(ctx context.Context, bucket, pref
|
|||
loi.NextMarker = entries.FilesVersions[len(entries.FilesVersions)-1].Name
|
||||
}
|
||||
|
||||
var prevPrefix string
|
||||
for _, entry := range entries.FilesVersions {
|
||||
for _, version := range entry.Versions {
|
||||
objInfo := version.ToObjectInfo(bucket, entry.Name)
|
||||
if HasSuffix(objInfo.Name, SlashSeparator) && !recursive {
|
||||
loi.Prefixes = append(loi.Prefixes, objInfo.Name)
|
||||
if objInfo.Name != prevPrefix {
|
||||
loi.Prefixes = append(loi.Prefixes, objInfo.Name)
|
||||
prevPrefix = objInfo.Name
|
||||
}
|
||||
continue
|
||||
}
|
||||
loi.Objects = append(loi.Objects, objInfo)
|
||||
|
|
Loading…
Reference in a new issue