Revision 48bb9c89 snf-pithos-backend/pithos/backends/modular.py
b/snf-pithos-backend/pithos/backends/modular.py | ||
---|---|---|
858 | 858 |
"""Update object metadata for a domain and return the new version.""" |
859 | 859 |
|
860 | 860 |
self._can_write(user, account, container, name) |
861 |
path, node = self._lookup_object(account, container, name) |
|
861 |
|
|
862 |
path, node = self._lookup_object(account, container, name, |
|
863 |
lock_container=True) |
|
862 | 864 |
src_version_id, dest_version_id = self._put_metadata( |
863 | 865 |
user, node, domain, meta, replace, |
864 | 866 |
update_statistics_ancestors_depth=1) |
... | ... | |
895 | 897 |
|
896 | 898 |
if user != account: |
897 | 899 |
raise NotAllowedError |
898 |
path = self._lookup_object(account, container, name)[0] |
|
900 |
path = self._lookup_object(account, container, name, |
|
901 |
lock_container=True)[0] |
|
899 | 902 |
self._check_permissions(path, permissions) |
900 | 903 |
self.permissions.access_set(path, permissions) |
901 | 904 |
self._report_sharing_change(user, account, path, {'members': |
... | ... | |
915 | 918 |
"""Update the public status of the object.""" |
916 | 919 |
|
917 | 920 |
self._can_write(user, account, container, name) |
918 |
path = self._lookup_object(account, container, name)[0] |
|
921 |
path = self._lookup_object(account, container, name, |
|
922 |
lock_container=True)[0] |
|
919 | 923 |
if not public: |
920 | 924 |
self.permissions.public_unset(path) |
921 | 925 |
else: |
... | ... | |
1039 | 1043 |
# Update objects with greater version and same hashmap |
1040 | 1044 |
# and size (fix metadata updates). |
1041 | 1045 |
self._can_write(user, account, container, name) |
1042 |
path, node = self._lookup_object(account, container, name) |
|
1046 |
path, node = self._lookup_object(account, container, name, |
|
1047 |
lock_container=True) |
|
1043 | 1048 |
props = self._get_version(node, version) |
1044 | 1049 |
versions = self.node.node_get_versions(node) |
1045 | 1050 |
for x in versions: |
... | ... | |
1059 | 1064 |
dest_meta = dest_meta or {} |
1060 | 1065 |
dest_version_ids = [] |
1061 | 1066 |
self._can_read(user, src_account, src_container, src_name) |
1062 |
path, node = self._lookup_object(src_account, src_container, src_name) |
|
1067 |
path, node = self._lookup_object(src_account, src_container, src_name, |
|
1068 |
lock_container=True) |
|
1063 | 1069 |
# TODO: Will do another fetch of the properties in duplicate version... |
1064 | 1070 |
props = self._get_version( |
1065 | 1071 |
node, src_version) # Check to see if source exists. |
... | ... | |
1146 | 1152 |
if user != account: |
1147 | 1153 |
raise NotAllowedError |
1148 | 1154 |
|
1155 |
# lookup object and lock container path also |
|
1156 |
path, node = self._lookup_object(account, container, name, |
|
1157 |
lock_container=True) |
|
1158 |
|
|
1149 | 1159 |
if until is not None: |
1150 |
path = '/'.join((account, container, name)) |
|
1151 |
node = self.node.node_lookup(path) |
|
1152 | 1160 |
if node is None: |
1153 | 1161 |
return |
1154 | 1162 |
hashes = [] |
... | ... | |
1182 | 1190 |
) |
1183 | 1191 |
return |
1184 | 1192 |
|
1185 |
path, node = self._lookup_object(account, container, name) |
|
1186 | 1193 |
if not self._exists(node): |
1187 | 1194 |
raise ItemNotExists('Object is deleted.') |
1188 | 1195 |
src_version_id, dest_version_id = self._put_version_duplicate( |
... | ... | |
1330 | 1337 |
raise ItemNotExists('Container does not exist') |
1331 | 1338 |
return path, node |
1332 | 1339 |
|
1333 |
def _lookup_object(self, account, container, name): |
|
1340 |
def _lookup_object(self, account, container, name, lock_container=False): |
|
1341 |
if lock_container: |
|
1342 |
self._lookup_container(account, container) |
|
1343 |
|
|
1334 | 1344 |
path = '/'.join((account, container, name)) |
1335 | 1345 |
node = self.node.node_lookup(path) |
1336 | 1346 |
if node is None: |
Also available in: Unified diff