From f71e1923438e7ec7f6fb2991f83d2fba6e382e66 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Wed, 3 Feb 2021 14:06:54 -0800 Subject: [PATCH] avoid listing an empty dir without __XLDIR__ (#11427) ``` minio server /tmp/disk{1...4} mc mb myminio/testbucket/ mkdir -p /tmp/disk{1..4}/testbucket/test-prefix/ ``` This would end up being listed in the current master, this PR fixes this situation. If a directory is a leaf dir we should it being listed, since it cannot be deleted anymore with DeleteObject, DeleteObjects() API calls because we natively support directories now. Avoid listing it and let healing purge this folder eventually in the background. --- cmd/metacache-walk.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cmd/metacache-walk.go b/cmd/metacache-walk.go index e9130e38e..fc73abf61 100644 --- a/cmd/metacache-walk.go +++ b/cmd/metacache-walk.go @@ -209,7 +209,9 @@ func (s *xlStorage) WalkDir(ctx context.Context, opts WalkDirOptions, wr io.Writ // NOT an object, append to stack (with slash) // If dirObject, but no metadata (which is unexpected) we skip it. if !isDirObj { - dirStack = append(dirStack, meta.name+slashSeparator) + if !isDirEmpty(pathJoin(volumeDir, meta.name+slashSeparator)) { + dirStack = append(dirStack, meta.name+slashSeparator) + } } case isSysErrNotDir(err): // skip