-
Notifications
You must be signed in to change notification settings - Fork 553
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mb: Add -p flag to ignore existing bucket/dir #2143
Conversation
cmd/client-s3.go
Outdated
@@ -762,6 +762,10 @@ func (c *s3Client) MakeBucket(region string) *probe.Error { | |||
} | |||
e := c.api.MakeBucket(bucket, region) | |||
if e != nil { | |||
// Ignore bucket already existing error when ignoreExisting flag is enabled | |||
if ignoreExisting && minio.ToErrorResponse(e).Code == "BucketAlreadyOwnedByYou" { | |||
return nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is one more Code to look for. BucketAlreadyExists
its reported by some regions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is one more Code to look for. BucketAlreadyExists its reported by some regions.
Thanks, done.
abf2367
to
93a14a9
Compare
Codecov Report
@@ Coverage Diff @@
## master #2143 +/- ##
=========================================
- Coverage 8.89% 8.88% -0.01%
=========================================
Files 92 92
Lines 6837 6844 +7
=========================================
Hits 608 608
- Misses 6094 6101 +7
Partials 135 135
Continue to review full report at Codecov.
|
cmd/mb-main.go
Outdated
@@ -32,6 +32,10 @@ var ( | |||
Value: "us-east-1", | |||
Usage: "Specify bucket region. Defaults to `us-east-1`.", | |||
}, | |||
cli.BoolFlag{ | |||
Name: "ignore-existing, p", | |||
Usage: "Ignore if remote bucket/directory exists", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove "remote" from the sentecne. We don't need to say that.
cmd/client-fs.go
Outdated
func (f *fsClient) MakeBucket(region string, ignoreExisting bool) *probe.Error { | ||
var e error | ||
if ignoreExisting { | ||
e = os.MkdirAll(f.PathURL.Path, 0777) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This changes backward compatibility... Lets do 'MkdirAllanyways until some release in future. Add a TODO to move it back to
Mkdir` in future.
If a remote directory/bucket exists, -p will still make mb cmd happy if the target already exists.
If a remote directory/bucket exists, -p will still make mb cmd
happy if the target already exists.
Fixes #2115