/* bucket already existed, might have raced with another bucket creation, or
* might be partial bucket creation that never completed. Read existing bucket
* info, verify that the reported bucket owner is the current user.
- * If all is ok then update the user's list of buckets
+ * If all is ok then update the user's list of buckets.
+ * Otherwise inform client about a name conflict.
*/
if (info.owner.compare(s->user.user_id) != 0) {
- ret = -ERR_BUCKET_EXISTS;
+ ret = -EEXIST;
return;
}
s->bucket = info.bucket;
if (ret < 0) {
ldout(s->cct, 0) << "WARNING: failed to unlink bucket: ret=" << ret << dendl;
}
- }
-
- if (ret == -EEXIST)
+ } else if (ret == -EEXIST || (ret == 0 && existed)) {
ret = -ERR_BUCKET_EXISTS;
+ }
}
int RGWDeleteBucket::verify_permission()