From 851f3c5f0cfc86ceed77c6bbfd3ac4bbbc3cb08d Mon Sep 17 00:00:00 2001 From: Anis Elleuch Date: Fri, 6 Aug 2021 14:35:11 +0100 Subject: [PATCH] Listing: Do not include marker in CommonPrefixes (#12021) (#12897) 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. --- cmd/erasure-server-sets.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cmd/erasure-server-sets.go b/cmd/erasure-server-sets.go index feafae2f8..6d510b3a6 100644 --- a/cmd/erasure-server-sets.go +++ b/cmd/erasure-server-sets.go @@ -913,6 +913,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 @@ -1324,6 +1330,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