Skip to content
This repository has been archived by the owner on Jan 3, 2024. It is now read-only.

Commit

Permalink
rgw/sfs: refactor of SFSBucket::merge_and_store_attrs()
Browse files Browse the repository at this point in the history
Refactored with a set_and_store_attrs semantics.
The previous implementation was started as if the method should implement a merge but the actual usage suggests set semantics.
The new implementation is more concise and simplified.

Related to: https://github.com/aquarist-labs/s3gw/issues/750
Signed-off-by: Giuseppe Baccini <[email protected]>
  • Loading branch information
Giuseppe Baccini committed Nov 13, 2023
1 parent 0aa6b88 commit 47bcffb
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions src/rgw/driver/sfs/bucket.cc
Original file line number Diff line number Diff line change
Expand Up @@ -404,21 +404,11 @@ int SFSBucket::
int SFSBucket::merge_and_store_attrs(
const DoutPrefixProvider* /*dpp*/, Attrs& new_attrs, optional_yield /*y*/
) {
for (auto& it : new_attrs) {
attrs[it.first] = it.second;

if (it.first == RGW_ATTR_ACL) {
auto lval = it.second.cbegin();
acls.decode(lval);
}
}
for (auto& it : attrs) {
auto it_find = new_attrs.find(it.first);
if (it_find == new_attrs.end()) {
// this is an old attr that is not defined in the new_attrs
// delete it
attrs.erase(it.first);
}
attrs = new_attrs;
auto it = attrs.end();
if ((it = attrs.find(RGW_ATTR_ACL)) != attrs.end()) {
auto lval = it->second.cbegin();
acls.decode(lval);
}

sfs::get_meta_buckets(get_store().db_conn)
Expand Down

0 comments on commit 47bcffb

Please sign in to comment.