diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index a2202caf07518..0c22e894fadef 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -1856,6 +1856,10 @@ static void prepare_add_del_attrs(const map& orig_attrs, if (aiter != std::end(out_attrs)) { out_attrs.erase(aiter); } + } else { + /* emplace() won't alter the map if the key is already present. + * This behaviour is fully intensional here. */ + out_attrs.emplace(kv); } } else if (out_attrs.find(name) == std::end(out_attrs)) { out_attrs[name] = kv.second; @@ -2773,11 +2777,23 @@ void RGWPutMetadataAccount::execute() return; } + op_ret = rgw_get_user_attrs_by_uid(store, s->user->user_id, orig_attrs, + &acct_op_tracker); + if (op_ret < 0) { + return; + } + rgw_get_request_metadata(s->cct, s->info, attrs, false); - RGWUserInfo orig_uinfo; - rgw_get_user_info_by_uid(store, s->user->user_id, orig_uinfo, &acct_op_tracker); + prepare_add_del_attrs(orig_attrs, rmattr_names, attrs); populate_with_generic_attrs(s, attrs); + RGWUserInfo orig_uinfo; + op_ret = rgw_get_user_info_by_uid(store, s->user->user_id, orig_uinfo, + &acct_op_tracker); + if (op_ret < 0) { + return; + } + /* Handle the TempURL-related stuff. */ map temp_url_keys; filter_out_temp_url(attrs, rmattr_names, temp_url_keys);