Revision 1e47e49d snf-pithos-backend/pithos/backends/modular.py
b/snf-pithos-backend/pithos/backends/modular.py | ||
---|---|---|
50 | 50 |
DEFAULT_CONTAINER_VERSIONING, NotAllowedError, QuotaError, |
51 | 51 |
BaseBackend, AccountExists, ContainerExists, AccountNotEmpty, |
52 | 52 |
ContainerNotEmpty, ItemNotExists, VersionNotExists, |
53 |
InvalidHash) |
|
53 |
InvalidHash, IllegalOperationError)
|
|
54 | 54 |
|
55 | 55 |
|
56 | 56 |
class DisabledAstakosClient(object): |
... | ... | |
1078 | 1078 |
props = self._get_version(node, version) |
1079 | 1079 |
if props[self.HASH] is None: |
1080 | 1080 |
return 0, () |
1081 |
hashmap = self.store.map_get(self._unhexlify_hash(props[self.HASH])) |
|
1082 |
return props[self.SIZE], [binascii.hexlify(x) for x in hashmap] |
|
1081 |
if props[self.HASH].startswith('archip:'): |
|
1082 |
hashmap = self.store.map_get_archipelago(props[self.HASH], |
|
1083 |
props[self.SIZE]) |
|
1084 |
return props[self.SIZE], [x for x in hashmap] |
|
1085 |
else: |
|
1086 |
hashmap = self.store.map_get(self._unhexlify_hash( |
|
1087 |
props[self.HASH])) |
|
1088 |
return props[self.SIZE], [binascii.hexlify(x) for x in hashmap] |
|
1083 | 1089 |
|
1084 | 1090 |
def _update_object_hash(self, user, account, container, name, size, type, |
1085 | 1091 |
hash, checksum, domain, meta, replace_meta, |
... | ... | |
1159 | 1165 |
replace_meta=False, permissions=None): |
1160 | 1166 |
"""Create/update an object's hashmap and return the new version.""" |
1161 | 1167 |
|
1168 |
for h in hashmap: |
|
1169 |
if h.startswith('archip_'): |
|
1170 |
raise IllegalOperationError( |
|
1171 |
'Cannot update Archipelago Volume hashmap.') |
|
1162 | 1172 |
meta = meta or {} |
1163 | 1173 |
if size == 0: # No such thing as an empty hashmap. |
1164 | 1174 |
hashmap = [self.put_block('')] |
... | ... | |
1451 | 1461 |
"""Return a block's data.""" |
1452 | 1462 |
|
1453 | 1463 |
logger.debug("get_block: %s", hash) |
1454 |
block = self.store.block_get(self._unhexlify_hash(hash)) |
|
1464 |
if hash.startswith('archip_'): |
|
1465 |
block = self.store.block_get_archipelago(hash) |
|
1466 |
else: |
|
1467 |
block = self.store.block_get(self._unhexlify_hash(hash)) |
|
1455 | 1468 |
if not block: |
1456 | 1469 |
raise ItemNotExists('Block does not exist') |
1457 | 1470 |
return block |
... | ... | |
1466 | 1479 |
"""Update a known block and return the hash.""" |
1467 | 1480 |
|
1468 | 1481 |
logger.debug("update_block: %s %s %s", hash, len(data), offset) |
1482 |
if hash.startswith('archip_'): |
|
1483 |
raise IllegalOperationError( |
|
1484 |
'Cannot update an Archipelago Volume block.') |
|
1469 | 1485 |
if offset == 0 and len(data) == self.block_size: |
1470 | 1486 |
return self.put_block(data) |
1471 | 1487 |
h = self.store.block_update(self._unhexlify_hash(hash), offset, data) |
Also available in: Unified diff