Revision fac5f6be snf-pithos-backend/pithos/backends/modular.py

b/snf-pithos-backend/pithos/backends/modular.py
49 49
                  DEFAULT_CONTAINER_VERSIONING, NotAllowedError, QuotaError,
50 50
                  BaseBackend, AccountExists, ContainerExists, AccountNotEmpty,
51 51
                  ContainerNotEmpty, ItemNotExists, VersionNotExists,
52
                  InvalidHash)
52
                  InvalidHash, IllegalOperationError)
53 53

  
54 54

  
55 55
class DisabledAstakosClient(object):
......
1040 1040
        props = self._get_version(node, version)
1041 1041
        if props[self.HASH] is None:
1042 1042
            return 0, ()
1043
        hashmap = self.store.map_get(self._unhexlify_hash(props[self.HASH]))
1044
        return props[self.SIZE], [binascii.hexlify(x) for x in hashmap]
1043
        if props[self.HASH].startswith('archip:'):
1044
            hashmap = self.store.map_get_archipelago(props[self.HASH],
1045
                                                     props[self.SIZE])
1046
            return props[self.SIZE], [x for x in hashmap]
1047
        else:
1048
            hashmap = self.store.map_get(self._unhexlify_hash(
1049
                props[self.HASH]))
1050
            return props[self.SIZE], [binascii.hexlify(x) for x in hashmap]
1045 1051

  
1046 1052
    def _update_object_hash(self, user, account, container, name, size, type,
1047 1053
                            hash, checksum, domain, meta, replace_meta,
......
1121 1127
                              replace_meta=False, permissions=None):
1122 1128
        """Create/update an object's hashmap and return the new version."""
1123 1129

  
1130
        for h in hashmap:
1131
            if h.startswith('archip_'):
1132
                raise IllegalOperationError(
1133
                    'Cannot update Archipelago Volume hashmap.')
1124 1134
        meta = meta or {}
1125 1135
        if size == 0:  # No such thing as an empty hashmap.
1126 1136
            hashmap = [self.put_block('')]
......
1409 1419
        """Return a block's data."""
1410 1420

  
1411 1421
        logger.debug("get_block: %s", hash)
1412
        block = self.store.block_get(self._unhexlify_hash(hash))
1422
        if hash.startswith('archip_'):
1423
            block = self.store.block_get_archipelago(hash)
1424
        else:
1425
            block = self.store.block_get(self._unhexlify_hash(hash))
1413 1426
        if not block:
1414 1427
            raise ItemNotExists('Block does not exist')
1415 1428
        return block
......
1424 1437
        """Update a known block and return the hash."""
1425 1438

  
1426 1439
        logger.debug("update_block: %s %s %s", hash, len(data), offset)
1440
        if hash.startswith('archip_'):
1441
            raise IllegalOperationError(
1442
                'Cannot update an Archipelago Volume block.')
1427 1443
        if offset == 0 and len(data) == self.block_size:
1428 1444
            return self.put_block(data)
1429 1445
        h = self.store.block_update(self._unhexlify_hash(hash), offset, data)

Also available in: Unified diff