Skip to content
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

Merged
merged 1 commit into from
Apr 28, 2017

Conversation

vadmeste
Copy link
Member

If a remote directory/bucket exists, -p will still make mb cmd
happy if the target already exists.

Fixes #2115

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
Copy link
Member

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.

Copy link
Member Author

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.

@vadmeste vadmeste force-pushed the issues/2115 branch 2 times, most recently from abf2367 to 93a14a9 Compare April 28, 2017 17:06
@codecov-io
Copy link

codecov-io commented Apr 28, 2017

Codecov Report

Merging #2143 into master will decrease coverage by <.01%.
The diff coverage is 18.18%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
cmd/mb-main.go 0% <0%> (ø) ⬆️
cmd/mirror-main.go 0% <0%> (ø) ⬆️
cmd/client-fs.go 28.64% <100%> (ø) ⬆️
cmd/client-s3.go 14.11% <14.28%> (-0.1%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 39aa635...eb8a8e9. Read the comment docs.

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",
Copy link
Member

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)
Copy link
Member

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 toMkdir` in future.

If a remote directory/bucket exists, -p will still make mb cmd
happy if the target already exists.
@deekoder deekoder merged commit e54962e into minio:master Apr 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants