- class swh.objstorage.multiplexer.filter.filter.ObjStorageFilter(storage)
Base implementation of a filter that allow inputs on ObjStorage or not.
This class copy the API of …objstorage in order to filter the inputs of this class.
If the operation is allowed, return the result of this operation applied to the destination implementation. Otherwise, just return without any operation.
This class is an abstract base class for a classic read/write storage. Filters can inherit from it and only redefine some methods in order to change behavior.
- check_config(*, check_write)
Check the object storage for proper configuration.
check_write – check whether writes to the objstorage will succeed
True if the storage is properly configured
- add(content, obj_id=None, check_presence=True, *args, **kwargs)
Add a new object to the object storage.
content (bytes) – object’s raw content to add in storage.
obj_id (bytes) – checksum of [bytes] using [ID_HASH_ALGO] algorithm. When given, obj_id will be trusted to match the bytes. If missing, obj_id will be computed on the fly.
check_presence (bool) – indicate if the presence of the content should be verified before adding the file.
the id (bytes) of the object into the storage.
- restore(content, obj_id=None, *args, **kwargs)
Restore a content that have been corrupted.
This function is identical to add but does not check if the object id is already in the file system. The default implementation provided by the current class is suitable for most cases.
- get(obj_id, *args, **kwargs)
Retrieve the content of a given object.
- check(obj_id, *args, **kwargs)
Perform an integrity check for a given object.
Verify that the file object is in place and that the content matches the object id.
- delete(obj_id, *args, **kwargs)
Delete an object.
- get_random(batch_size, *args, **kwargs)
Get random ids of existing contents.
This method is used in order to get random ids to perform content integrity verifications on random contents.
batch_size (int) – Number of ids that will be given
An iterable of ids (bytes) of contents that are in the current object storage.