From 501b791408baa2a03592fb377916f34e6183e8f0 Mon Sep 17 00:00:00 2001 From: ebozduman Date: Wed, 10 Mar 2021 23:13:55 -0800 Subject: [PATCH] Fixes conflicting Failure&Successful msgs in 'mc rb' output (#3616) --- cmd/client-s3.go | 12 +++++++++++- cmd/rb-main.go | 3 ++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/cmd/client-s3.go b/cmd/client-s3.go index 7801dd1b..e36b4f53 100644 --- a/cmd/client-s3.go +++ b/cmd/client-s3.go @@ -1070,7 +1070,9 @@ func (c *S3Client) Remove(ctx context.Context, isIncomplete, isRemoveBucket, isB defer close(errorCh) if isRemoveBucket { if _, object := c.url2BucketAndObject(); object != "" { - errorCh <- probe.NewError(errors.New("cannot delete prefixes with `mc rb` command - Use `mc rm` instead")) + errorCh <- probe.NewError(errors.New( + "use `mc rm` command to delete prefixes, or point your" + + " bucket directly, `mc rb //`")) return } } @@ -1159,6 +1161,14 @@ func (c *S3Client) Remove(ctx context.Context, isIncomplete, isRemoveBucket, isB // Write remove objects status to errorCh if statusCh != nil { for removeStatus := range statusCh { + // If the removeStatus error message is: + // "Object is WORM protected and cannot be overwritten", + // it is too generic. We have the object's name and vid. + // Adding the object's name and version id into the error msg + removeStatus.Err = errors.New(strings.Replace( + removeStatus.Err.Error(), "Object is WORM protected", + "Object, '"+removeStatus.ObjectName+" (Version ID="+ + removeStatus.VersionID+")' is WORM protected", 1)) errorCh <- probe.NewError(removeStatus.Err) } } diff --git a/cmd/rb-main.go b/cmd/rb-main.go index ac3fe276..afbf4cc7 100644 --- a/cmd/rb-main.go +++ b/cmd/rb-main.go @@ -167,8 +167,9 @@ func deleteBucket(ctx context.Context, url string) *probe.Error { } }() + // Give up on the first error. for perr := range errorCh { - errorIf(perr.Trace(url), "Failed to remove `"+url+"`, continuing..") + return perr } return nil }