Listing: Do not include marker in CommonPrefixes (#12021)

Walk() and Merge code can return dir__XLDIR__ as the last element 
on a page list and dir__XLDIR__ as the first element in the next list page.

dir__XLDIR__ is shown in the second-page list because the marker set to
dir/ is meant to skip dir/ and not dir__XLDIR__

To fix this, the code will avoid adding the marker itself to the listing
result.
This commit is contained in:
Anis Elleuch 2021-04-08 22:21:20 +01:00 committed by GitHub
parent edaf7bc19d
commit 07d7dd6321
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -930,6 +930,12 @@ func (z *erasureServerSets) listObjects(ctx context.Context, bucket, prefix, mar
for _, entry := range entries.Files {
objInfo := entry.ToObjectInfo(entry.Volume, entry.Name)
// Always avoid including the marker in the result, this is
// needed to avoid including dir__XLDIR__ and dir/ twice in
// different listing pages
if objInfo.Name == marker {
continue
}
if HasSuffix(objInfo.Name, SlashSeparator) && !recursive {
loi.Prefixes = append(loi.Prefixes, objInfo.Name)
continue
@ -1411,6 +1417,12 @@ func (z *erasureServerSets) listObjectVersions(ctx context.Context, bucket, pref
for _, entry := range entries.FilesVersions {
for _, version := range entry.Versions {
objInfo := version.ToObjectInfo(bucket, entry.Name)
// Always avoid including the marker in the result, this is
// needed to avoid including dir__XLDIR__ and dir/ twice in
// different listing pages
if objInfo.Name == marker && objInfo.VersionID == versionMarker {
continue
}
if HasSuffix(objInfo.Name, SlashSeparator) && !recursive {
loi.Prefixes = append(loi.Prefixes, objInfo.Name)
continue