Revision cf7a6494 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)
1020
        path, node = self._lookup_object(src_account, src_container, src_name)
1026
        path, node = self._lookup_object(src_account, src_container, src_name,
1027
                                         lock_container=True)
1021 1028
        # TODO: Will do another fetch of the properties in duplicate version...
1022 1029
        props = self._get_version(
1023 1030
            node, src_version)  # Check to see if source exists.
......
1026 1033
        size = props[self.SIZE]
1027 1034
        is_copy = not is_move and (src_account, src_container, src_name) != (
1028 1035
            dest_account, dest_container, dest_name)  # New uuid.
1036
        # _update_object_hash() locks destination path
1029 1037
        dest_version_ids.append(self._update_object_hash(user, dest_account, dest_container, dest_name, size, type, hash, None, dest_domain, dest_meta, replace_meta, permissions, src_node=node, src_version_id=src_version_id, is_copy=is_copy))
1030 1038
        if is_move and (src_account, src_container, src_name) != (dest_account, dest_container, dest_name):
1031 1039
            self._delete_object(user, src_account, src_container, src_name)
......
1048 1056
                dest_prefix = dest_name + delimiter if not dest_name.endswith(
1049 1057
                    delimiter) else dest_name
1050 1058
                vdest_name = path.replace(prefix, dest_prefix, 1)
1059
                # _update_object_hash() locks destination path
1051 1060
                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 1061
                if is_move and (src_account, src_container, src_name) != (dest_account, dest_container, dest_name):
1053 1062
                    self._delete_object(user, src_account, src_container, path)
......
1077 1086
        if user != account:
1078 1087
            raise NotAllowedError
1079 1088

  
1089
        # lookup object and lock container path also
1090
        path, node = self._lookup_object(account, container, name,
1091
                                         lock_container=True)
1092

  
1080 1093
        if until is not None:
1081 1094
            path = '/'.join((account, container, name))
1082 1095
            node = self.node.node_lookup(path)
......
1113 1126
            )
1114 1127
            return
1115 1128

  
1116
        path, node = self._lookup_object(account, container, name)
1117 1129
        src_version_id, dest_version_id = self._put_version_duplicate(
1118 1130
            user, node, size=0, type='', hash=None, checksum='',
1119 1131
            cluster=CLUSTER_DELETED, update_statistics_ancestors_depth=1)
......
1255 1267
            raise ItemNotExists('Container does not exist')
1256 1268
        return path, node
1257 1269

  
1258
    def _lookup_object(self, account, container, name):
1270
    def _lookup_object(self, account, container, name, lock_container=False):
1271
        if lock_container:
1272
            self._lookup_container(account, container)
1273

  
1259 1274
        path = '/'.join((account, container, name))
1260 1275
        node = self.node.node_lookup(path)
1261 1276
        if node is None:

Also available in: Unified diff