diff --git a/cmd/metacache-server-pool.go b/cmd/metacache-server-pool.go index c78a1e7f36748..f034fa268aa1c 100644 --- a/cmd/metacache-server-pool.go +++ b/cmd/metacache-server-pool.go @@ -97,6 +97,7 @@ func (z *erasureServerPools) listPath(ctx context.Context, o *listPathOptions) ( o.parseMarker() o.BaseDir = baseDirFromPrefix(o.Prefix) o.Transient = o.Transient || isReservedOrInvalidBucket(o.Bucket, false) + o.SetFilter() if o.Transient { o.Create = false } diff --git a/cmd/metacache-walk.go b/cmd/metacache-walk.go index 5825e3ed7ad2d..622f7a3e7e48a 100644 --- a/cmd/metacache-walk.go +++ b/cmd/metacache-walk.go @@ -110,6 +110,11 @@ func (s *xlStorage) WalkDir(ctx context.Context, opts WalkDirOptions, wr io.Writ var scanDir func(path string) error scanDir = func(current string) error { + // always skip the directory that doesn't match the prefix + if len(current) > 0 && !strings.HasPrefix(current, prefix) { + return nil + } + // Skip forward, if requested... forward := "" if len(opts.ForwardTo) > 0 && strings.HasPrefix(opts.ForwardTo, current) { @@ -138,9 +143,6 @@ func (s *xlStorage) WalkDir(ctx context.Context, opts WalkDirOptions, wr io.Writ } dirObjects := make(map[string]struct{}) for i, entry := range entries { - if len(prefix) > 0 && !strings.HasPrefix(entry, prefix) { - continue - } if len(forward) > 0 && entry < forward { continue } @@ -197,7 +199,6 @@ func (s *xlStorage) WalkDir(ctx context.Context, opts WalkDirOptions, wr io.Writ // Process in sort order. sort.Strings(entries) dirStack := make([]string, 0, 5) - prefix = "" // Remove prefix after first level. if len(forward) > 0 { idx := sort.SearchStrings(entries, forward) if idx > 0 {