From 32c13f2977f27a3261eb61438e834f8d1f8d9c9f Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Mon, 3 Aug 2020 15:32:42 -0700 Subject: [PATCH] fix: rb command regression deleting bucket (#3337) --- cmd/client-s3.go | 6 ++++++ cmd/rb-main.go | 9 ++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/cmd/client-s3.go b/cmd/client-s3.go index 63f5f7e4..d6c4d464 100644 --- a/cmd/client-s3.go +++ b/cmd/client-s3.go @@ -1564,6 +1564,12 @@ func (c *S3Client) snapshot(ctx context.Context, isRecursive bool, timeRef time. go func() { defer close(contentCh) for objectVersion := range c.listVersions(ctx, bucket, object, isRecursive, timeRef, includeOlderVersions, withDeleteMarkers) { + if objectVersion.Err != nil { + contentCh <- &ClientContent{ + Err: probe.NewError(objectVersion.Err), + } + continue + } contentCh <- c.objectInfo2ClientContent(bucket, objectVersion) } }() diff --git a/cmd/rb-main.go b/cmd/rb-main.go index 695b0bfb..030a41c8 100644 --- a/cmd/rb-main.go +++ b/cmd/rb-main.go @@ -62,10 +62,10 @@ FLAGS: EXAMPLES: 1. Remove an empty bucket on Amazon S3 cloud storage {{.Prompt}} {{.HelpName}} s3/mybucket - + 2. Remove a directory hierarchy. {{.Prompt}} {{.HelpName}} /tmp/this/new/dir1 - + 3. Remove bucket 'jazz-songs' and all its contents {{.Prompt}} {{.HelpName}} --force s3/jazz-songs @@ -235,7 +235,10 @@ func mainRemoveBucket(cliCtx *cli.Context) error { } listCtx, listCancel := context.WithCancel(ctx) - for range clnt.List(listCtx, opts) { + for obj := range clnt.List(listCtx, opts) { + if obj.Err != nil { + continue + } isEmpty = false break }