From 2aac50571d8cd70358f1577d477d768266286554 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Fri, 30 Sep 2022 15:44:21 -0700 Subject: [PATCH] fix: de-duplicate conflicting object names on namespace (#15772) --- cmd/metacache-entries.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cmd/metacache-entries.go b/cmd/metacache-entries.go index e8a9af4a6..12e6047b2 100644 --- a/cmd/metacache-entries.go +++ b/cmd/metacache-entries.go @@ -22,6 +22,7 @@ import ( "context" "errors" "os" + "path" "sort" "strings" @@ -684,7 +685,14 @@ func mergeEntryChannels(ctx context.Context, in []chan metaCacheEntry, out chan< bestIdx = otherIdx continue } - if best.name == other.name { + // We should make sure to avoid objects and directories + // of this fashion such as + // - foo-1 + // - foo-1/ + // we should avoid this situation by making sure that + // we compare the `foo-1/` after path.Clean() to + // de-dup the entries. + if path.Clean(best.name) == path.Clean(other.name) { if compareMeta(best, other) { // Replace "best" if err := selectFrom(bestIdx); err != nil {