}
}
+/* Fuse resource metadata basing on original attributes in @orig_attrs, set
+ * of _custom_ attribute names to remove in @rmattr_names and attributes in
+ * @out_attrs. Place results in @out_attrs.
+ *
+ * NOTE: it's supposed that all special attrs already present in @out_attrs
+ * will be preserved without any change. Special attributes are those which
+ * names start with RGW_ATTR_META_PREFIX. They're complement to custom ones
+ * used for X-Account-Meta-*, X-Container-Meta-*, X-Amz-Meta and so on. */
static void prepare_add_del_attrs(const map<string, bufferlist>& orig_attrs,
const set<string>& rmattr_names,
map<string, bufferlist>& out_attrs)
}
}
- if (need_metadata_upload()) {
- rgw_get_request_metadata(s->cct, s->info, attrs, false);
- prepare_add_del_attrs(s->bucket_attrs, rmattr_names, attrs);
- populate_with_generic_attrs(s, attrs);
- }
-
+ /* Encode special metadata first as we're using std::map::emplace under
+ * the hood. This method will add the new items only if the map doesn't
+ * contain such keys yet. */
policy.encode(aclbl);
emplace_attr(RGW_ATTR_ACL, std::move(aclbl));
cors_config.encode(corsbl);
emplace_attr(RGW_ATTR_CORS, std::move(corsbl));
}
+
+ if (need_metadata_upload()) {
+ /* It's supposed that following functions WILL NOT change any special
+ * attributes (like RGW_ATTR_ACL) if they are already present in attrs. */
+ rgw_get_request_metadata(s->cct, s->info, attrs, false);
+ prepare_add_del_attrs(s->bucket_attrs, rmattr_names, attrs);
+ populate_with_generic_attrs(s, attrs);
+ }
+
s->bucket.tenant = s->bucket_tenant; /* ignored if bucket exists */
s->bucket.name = s->bucket_name;
op_ret = store->create_bucket(*(s->user), s->bucket, zonegroup_id,
return;
}
- orig_attrs = s->bucket_attrs; /* XXX map copy */
- prepare_add_del_attrs(orig_attrs, rmattr_names, attrs);
- populate_with_generic_attrs(s, attrs);
-
+ /* Encode special metadata first as we're using std::map::emplace under
+ * the hood. This method will add the new items only if the map doesn't
+ * contain such keys yet. */
if (has_policy) {
buffer::list bl;
policy.encode(bl);
emplace_attr(RGW_ATTR_CORS, std::move(bl));
}
+ /* It's supposed that following functions WILL NOT change any special
+ * attributes (like RGW_ATTR_ACL) if they are already present in attrs. */
+ orig_attrs = s->bucket_attrs; /* XXX map copy */
+ prepare_add_del_attrs(orig_attrs, rmattr_names, attrs);
+ populate_with_generic_attrs(s, attrs);
+
s->bucket_info.swift_ver_location = swift_ver_location;
s->bucket_info.swift_versioning = (!swift_ver_location.empty());