Revision 683d4324 snf-pithos-backend/pithos/backends/modular.py
b/snf-pithos-backend/pithos/backends/modular.py | ||
---|---|---|
827 | 827 |
logger.debug("update_object_meta: %s %s %s %s %s %s %s", |
828 | 828 |
user, account, container, name, domain, meta, replace) |
829 | 829 |
self._can_write(user, account, container, name) |
830 |
path, node = self._lookup_object(account, container, name) |
|
830 |
|
|
831 |
path, node = self._lookup_object(account, container, name, |
|
832 |
lock_container=True) |
|
831 | 833 |
src_version_id, dest_version_id = self._put_metadata( |
832 | 834 |
user, node, domain, meta, replace, |
833 | 835 |
update_statistics_ancestors_depth=1) |
... | ... | |
863 | 865 |
user, account, container, name, permissions) |
864 | 866 |
if user != account: |
865 | 867 |
raise NotAllowedError |
866 |
path = self._lookup_object(account, container, name)[0] |
|
868 |
path = self._lookup_object(account, container, name, |
|
869 |
lock_container=True)[0] |
|
867 | 870 |
self._check_permissions(path, permissions) |
868 | 871 |
self.permissions.access_set(path, permissions) |
869 | 872 |
self._report_sharing_change(user, account, path, {'members': |
... | ... | |
887 | 890 |
logger.debug("update_object_public: %s %s %s %s %s", user, |
888 | 891 |
account, container, name, public) |
889 | 892 |
self._can_write(user, account, container, name) |
890 |
path = self._lookup_object(account, container, name)[0] |
|
893 |
path = self._lookup_object(account, container, name, |
|
894 |
lock_container=True)[0] |
|
891 | 895 |
if not public: |
892 | 896 |
self.permissions.public_unset(path) |
893 | 897 |
else: |
... | ... | |
993 | 997 |
raise ie |
994 | 998 |
|
995 | 999 |
hash = map.hash() |
1000 |
# _update_object_hash() locks destination path |
|
996 | 1001 |
dest_version_id = self._update_object_hash(user, account, container, name, size, type, binascii.hexlify(hash), checksum, domain, meta, replace_meta, permissions) |
997 | 1002 |
self.store.map_put(hash, map) |
998 | 1003 |
return dest_version_id |
... | ... | |
1005 | 1010 |
user, account, container, name, version, checksum) |
1006 | 1011 |
# Update objects with greater version and same hashmap and size (fix metadata updates). |
1007 | 1012 |
self._can_write(user, account, container, name) |
1008 |
path, node = self._lookup_object(account, container, name) |
|
1013 |
path, node = self._lookup_object(account, container, name, |
|
1014 |
lock_container=True) |
|
1009 | 1015 |
props = self._get_version(node, version) |
1010 | 1016 |
versions = self.node.node_get_versions(node) |
1011 | 1017 |
for x in versions: |
... | ... | |
1017 | 1023 |
dest_meta = dest_meta or {} |
1018 | 1024 |
dest_version_ids = [] |
1019 | 1025 |
self._can_read(user, src_account, src_container, src_name) |
1026 |
|
|
1027 |
src_container_path = '/'.join((src_account, src_container)) |
|
1028 |
dest_container_path = '/'.join((dest_account, dest_container)) |
|
1029 |
# Lock container paths in alphabetical order |
|
1030 |
if src_container_path < dest_container_path: |
|
1031 |
self._lookup_container(src_account, src_container) |
|
1032 |
self._lookup_container(dest_account, dest_container) |
|
1033 |
else: |
|
1034 |
self._lookup_container(dest_account, dest_container) |
|
1035 |
self._lookup_container(src_account, src_container) |
|
1036 |
|
|
1020 | 1037 |
path, node = self._lookup_object(src_account, src_container, src_name) |
1021 | 1038 |
# TODO: Will do another fetch of the properties in duplicate version... |
1022 | 1039 |
props = self._get_version( |
... | ... | |
1048 | 1065 |
dest_prefix = dest_name + delimiter if not dest_name.endswith( |
1049 | 1066 |
delimiter) else dest_name |
1050 | 1067 |
vdest_name = path.replace(prefix, dest_prefix, 1) |
1068 |
# _update_object_hash() locks destination path |
|
1051 | 1069 |
dest_version_ids.append(self._update_object_hash(user, dest_account, dest_container, vdest_name, size, vtype, hash, None, dest_domain, meta={}, replace_meta=False, permissions=None, src_node=node, src_version_id=src_version_id, is_copy=is_copy)) |
1052 | 1070 |
if is_move and (src_account, src_container, src_name) != (dest_account, dest_container, dest_name): |
1053 | 1071 |
self._delete_object(user, src_account, src_container, path) |
... | ... | |
1077 | 1095 |
if user != account: |
1078 | 1096 |
raise NotAllowedError |
1079 | 1097 |
|
1098 |
# lookup object and lock container path also |
|
1099 |
path, node = self._lookup_object(account, container, name, |
|
1100 |
lock_container=True) |
|
1101 |
|
|
1080 | 1102 |
if until is not None: |
1081 | 1103 |
path = '/'.join((account, container, name)) |
1082 | 1104 |
node = self.node.node_lookup(path) |
... | ... | |
1113 | 1135 |
) |
1114 | 1136 |
return |
1115 | 1137 |
|
1116 |
path, node = self._lookup_object(account, container, name) |
|
1117 | 1138 |
src_version_id, dest_version_id = self._put_version_duplicate( |
1118 | 1139 |
user, node, size=0, type='', hash=None, checksum='', |
1119 | 1140 |
cluster=CLUSTER_DELETED, update_statistics_ancestors_depth=1) |
... | ... | |
1255 | 1276 |
raise ItemNotExists('Container does not exist') |
1256 | 1277 |
return path, node |
1257 | 1278 |
|
1258 |
def _lookup_object(self, account, container, name): |
|
1279 |
def _lookup_object(self, account, container, name, lock_container=False): |
|
1280 |
if lock_container: |
|
1281 |
self._lookup_container(account, container) |
|
1282 |
|
|
1259 | 1283 |
path = '/'.join((account, container, name)) |
1260 | 1284 |
node = self.node.node_lookup(path) |
1261 | 1285 |
if node is None: |
Also available in: Unified diff