Changeset View
Changeset View
Standalone View
Standalone View
swh/objstorage/cloud/objstorage_cloud.py
Show First 20 Lines • Show All 116 Lines • ▼ Show 20 Lines | def check(self, obj_id): | ||||
# Check that the file exists, as _get_object raises ObjNotFoundError | # Check that the file exists, as _get_object raises ObjNotFoundError | ||||
self._get_object(obj_id) | self._get_object(obj_id) | ||||
# Check the content integrity | # Check the content integrity | ||||
obj_content = self.get(obj_id) | obj_content = self.get(obj_id) | ||||
content_obj_id = compute_hash(obj_content) | content_obj_id = compute_hash(obj_content) | ||||
if content_obj_id != obj_id: | if content_obj_id != obj_id: | ||||
raise Error(obj_id) | raise Error(obj_id) | ||||
def delete(self, obj_id): | |||||
obj = self._get_object(obj_id) | |||||
return self.driver.delete_object(obj) | |||||
def _get_object(self, obj_id): | def _get_object(self, obj_id): | ||||
"""Get a Libcloud wrapper for an object pointer. | """Get a Libcloud wrapper for an object pointer. | ||||
This wrapper does not retrieve the content of the object | This wrapper does not retrieve the content of the object | ||||
directly. | directly. | ||||
""" | """ | ||||
hex_obj_id = hashutil.hash_to_hex(obj_id) | hex_obj_id = hashutil.hash_to_hex(obj_id) | ||||
Show All 31 Lines |