Changeset View
Changeset View
Standalone View
Standalone View
swh/objstorage/backends/seaweed.py
Show First 20 Lines • Show All 143 Lines • ▼ Show 20 Lines | def add(self, content, obj_id=None, check_presence=True): | ||||
return obj_id | return obj_id | ||||
def restore(self, content, obj_id=None): | def restore(self, content, obj_id=None): | ||||
return self.add(content, obj_id, check_presence=False) | return self.add(content, obj_id, check_presence=False) | ||||
def get(self, obj_id): | def get(self, obj_id): | ||||
try: | try: | ||||
obj = self.wf.get(self._path(obj_id)) | obj = self.wf.get(self._path(obj_id)) | ||||
return decompressors[self.compression](obj) | |||||
except Exception: | except Exception: | ||||
raise ObjNotFoundError(obj_id) | raise ObjNotFoundError(obj_id) | ||||
d = decompressors[self.compression]() | |||||
ret = d.decompress(obj) | |||||
if d.unused_data: | |||||
hex_obj_id = hashutil.hash_to_hex(obj_id) | |||||
raise Error('Corrupt object %s: trailing data found' % hex_obj_id) | |||||
return ret | |||||
def check(self, obj_id): | def check(self, 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): | def delete(self, obj_id): | ||||
Show All 39 Lines |