From fa4da03a4f47ab05d6f8e5691501c5d81ab8506d Mon Sep 17 00:00:00 2001 From: Anis Elleuch Date: Fri, 23 Oct 2020 01:35:51 +0100 Subject: [PATCH] ls: Fix listing buckets with --versions (#3462) mc ls --versions alias/ has an unexpected output due to missing consideration of this use case. This commit fixes the behavior. --- cmd/client-s3.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cmd/client-s3.go b/cmd/client-s3.go index d9783bb7..34bf06da 100644 --- a/cmd/client-s3.go +++ b/cmd/client-s3.go @@ -1654,8 +1654,16 @@ func (c *S3Client) versionedList(ctx context.Context, contentCh chan *ClientCont } return } - for _, bucket := range buckets { + // List only buckets if not recursive + if !opts.IsRecursive { + for _, bucket := range buckets { + contentCh <- c.bucketInfo2ClientContent(bucket) + } + return + } + + for _, bucket := range buckets { if opts.ShowDir == DirFirst { contentCh <- c.bucketInfo2ClientContent(bucket) }