Changeset View
Changeset View
Standalone View
Standalone View
swh/objstorage/backends/seaweedfs/objstorage.py
Show First 20 Lines • Show All 108 Lines • ▼ Show 20 Lines | def get(self, obj_id: ObjId) -> bytes: | ||||
hex_obj_id = objid_to_default_hex(obj_id) | hex_obj_id = objid_to_default_hex(obj_id) | ||||
raise Error("Corrupt object %s: trailing data found" % hex_obj_id) | raise Error("Corrupt object %s: trailing data found" % hex_obj_id) | ||||
return ret | return ret | ||||
def check(self, obj_id: ObjId) -> None: | def check(self, obj_id: ObjId) -> None: | ||||
# 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 isinstance(obj_id, dict): | |||||
obj_id = obj_id[self.PRIMARY_HASH] | |||||
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: ObjId): | def delete(self, obj_id: ObjId): | ||||
super().delete(obj_id) # Check delete permission | super().delete(obj_id) # Check delete permission | ||||
if obj_id not in self: | if obj_id not in self: | ||||
raise ObjNotFoundError(obj_id) | raise ObjNotFoundError(obj_id) | ||||
self.wf.delete(self._path(obj_id)) | self.wf.delete(self._path(obj_id)) | ||||
Show All 37 Lines |