forked from TrueCloudLab/rclone
b2: return error when we try to create a bucket which someone else owns #645
This commit is contained in:
parent
140a3d0aef
commit
d9bba67d18
1 changed files with 10 additions and 1 deletions
11
b2/b2.go
11
b2/b2.go
|
@ -695,7 +695,16 @@ func (f *Fs) Mkdir() error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if apiErr, ok := err.(*api.Error); ok {
|
if apiErr, ok := err.(*api.Error); ok {
|
||||||
if apiErr.Code == "duplicate_bucket_name" {
|
if apiErr.Code == "duplicate_bucket_name" {
|
||||||
return nil
|
// Check this is our bucket - buckets are globally unique and this
|
||||||
|
// might be someone elses.
|
||||||
|
_, getBucketErr := f.getBucketID()
|
||||||
|
if getBucketErr == nil {
|
||||||
|
// found so it is our bucket
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if getBucketErr != fs.ErrorDirNotFound {
|
||||||
|
fs.Debug(f, "Error checking bucket exists: %v", getBucketErr)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return errors.Wrap(err, "failed to create bucket")
|
return errors.Wrap(err, "failed to create bucket")
|
||||||
|
|
Loading…
Reference in a new issue