Changeset View
Changeset View
Standalone View
Standalone View
swh/objstorage/interface.py
Show First 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | def __contains__(self, obj_id: ObjId) -> bool: | ||||
Returns: | Returns: | ||||
True if and only if the object is present in the current object | True if and only if the object is present in the current object | ||||
storage. | storage. | ||||
""" | """ | ||||
... | ... | ||||
@remote_api_endpoint("content/add") | @remote_api_endpoint("content/add") | ||||
def add(self, content: bytes, obj_id: ObjId, check_presence: bool = True) -> ObjId: | def add(self, content: bytes, obj_id: ObjId, check_presence: bool = True) -> None: | ||||
"""Add a new object to the object storage. | """Add a new object to the object storage. | ||||
Args: | Args: | ||||
content: object's raw content to add in storage. | content: object's raw content to add in storage. | ||||
obj_id: checksum of [bytes] using [ID_HASH_ALGO] | obj_id: checksum of [bytes] using [ID_HASH_ALGO] | ||||
algorithm. It is trusted to match the bytes. | algorithm. It is trusted to match the bytes. | ||||
check_presence (bool): indicate if the presence of the | check_presence (bool): indicate if the presence of the | ||||
content should be verified before adding the file. | content should be verified before adding the file. | ||||
Show All 13 Lines | def add_batch(self, contents, check_presence=True) -> Dict: | ||||
Returns: | Returns: | ||||
the summary of objects added to the storage (count of object, | the summary of objects added to the storage (count of object, | ||||
count of bytes object) | count of bytes object) | ||||
""" | """ | ||||
... | ... | ||||
def restore(self, content: bytes, obj_id: ObjId): | def restore(self, content: bytes, obj_id: ObjId) -> None: | ||||
"""Restore a content that have been corrupted. | """Restore a content that have been corrupted. | ||||
This function is identical to add but does not check if | This function is identical to add but does not check if | ||||
the object id is already in the file system. | the object id is already in the file system. | ||||
The default implementation provided by the current class is | The default implementation provided by the current class is | ||||
suitable for most cases. | suitable for most cases. | ||||
Args: | Args: | ||||
▲ Show 20 Lines • Show All 108 Lines • Show Last 20 Lines |