Revision e851ad95
b/snf-pithos-backend/pithos/backends/modular.py | ||
---|---|---|
1160 | 1160 |
return dest_version_id |
1161 | 1161 |
|
1162 | 1162 |
@debug_method |
1163 |
@backend_method |
|
1164 |
def register_object_map(self, user, account, container, name, size, type, |
|
1165 |
mapfile, checksum='', domain='pithos', meta=None, |
|
1166 |
replace_meta=False, permissions=None): |
|
1167 |
"""Register an object mapfile without providing any data. |
|
1168 |
|
|
1169 |
Lock the container path, create a node pointing to the object path, |
|
1170 |
create a version pointing to the mapfile |
|
1171 |
and issue the size change in the quotaholder. |
|
1172 |
|
|
1173 |
:param user: the user account which performs the action |
|
1174 |
|
|
1175 |
:param account: the account under which the object resides |
|
1176 |
|
|
1177 |
:param container: the container under which the object resides |
|
1178 |
|
|
1179 |
:param name: the object name |
|
1180 |
|
|
1181 |
:param size: the object size |
|
1182 |
|
|
1183 |
:param type: the object mimetype |
|
1184 |
|
|
1185 |
:param mapfile: the mapfile pointing to the object data |
|
1186 |
|
|
1187 |
:param checkcum: the md5 checksum (optional) |
|
1188 |
|
|
1189 |
:param domain: the object domain |
|
1190 |
|
|
1191 |
:param meta: a dict with custom object metadata |
|
1192 |
|
|
1193 |
:param replace_meta: replace existing metadata or not |
|
1194 |
|
|
1195 |
:param permissions: a dict with the read and write object permissions |
|
1196 |
|
|
1197 |
:returns: the new object uuid |
|
1198 |
|
|
1199 |
:raises: ItemNotExists, NotAllowedError, QuotaError |
|
1200 |
""" |
|
1201 |
|
|
1202 |
meta = meta or {} |
|
1203 |
try: |
|
1204 |
self.lock_container_path = True |
|
1205 |
self.put_container(user, account, container, policy=None) |
|
1206 |
except ContainerExists: |
|
1207 |
pass |
|
1208 |
finally: |
|
1209 |
self.lock_container_path = False |
|
1210 |
dest_version_id = self._update_object_hash( |
|
1211 |
user, account, container, name, size, type, mapfile, checksum, |
|
1212 |
domain, meta, replace_meta, permissions) |
|
1213 |
return self.node.version_get_properties(dest_version_id, |
|
1214 |
keys=('uuid',))[0] |
|
1215 |
|
|
1216 |
@debug_method |
|
1163 | 1217 |
def update_object_hashmap(self, user, account, container, name, size, type, |
1164 | 1218 |
hashmap, checksum, domain, meta=None, |
1165 | 1219 |
replace_meta=False, permissions=None): |
... | ... | |
1168 | 1222 |
for h in hashmap: |
1169 | 1223 |
if h.startswith('archip_'): |
1170 | 1224 |
raise IllegalOperationError( |
1171 |
'Cannot update Archipelago Volume hashmap.') |
|
1225 |
'Cannot update Archipelago Volume hashmap.')
|
|
1172 | 1226 |
meta = meta or {} |
1173 | 1227 |
if size == 0: # No such thing as an empty hashmap. |
1174 | 1228 |
hashmap = [self.put_block('')] |
... | ... | |
1481 | 1535 |
logger.debug("update_block: %s %s %s", hash, len(data), offset) |
1482 | 1536 |
if hash.startswith('archip_'): |
1483 | 1537 |
raise IllegalOperationError( |
1484 |
'Cannot update an Archipelago Volume block.') |
|
1538 |
'Cannot update an Archipelago Volume block.')
|
|
1485 | 1539 |
if offset == 0 and len(data) == self.block_size: |
1486 | 1540 |
return self.put_block(data) |
1487 | 1541 |
h = self.store.block_update(self._unhexlify_hash(hash), offset, data) |
Also available in: Unified diff