swh.objstorage.multiplexer.filter.read_write_filter module

class swh.objstorage.multiplexer.filter.read_write_filter.ReadObjStorageFilter(storage)[source]

Bases: swh.objstorage.multiplexer.filter.filter.ObjStorageFilter

Filter that disable write operation of the storage.

Writes will always succeed without doing any actual write operations.

check_config(*, check_write)[source]

Check the object storage for proper configuration.

Parameters

check_write – check whether writes to the objstorage will succeed

Returns

True if the storage is properly configured

add(*args, **kwargs)[source]

Add a new object to the object storage.

Parameters
  • 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.

Returns

the id (bytes) of the object into the storage.

restore(*args, **kwargs)[source]

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.

Parameters
  • content (bytes) – object’s raw content to add in storage

  • obj_id (bytes) – checksum of bytes as computed by ID_HASH_ALGO. When given, obj_id will be trusted to match bytes. If missing, obj_id will be computed on the fly.

delete(*args, **kwargs)[source]

Delete an object.

Parameters

obj_id (bytes) – object identifier.

Raises

ObjNotFoundError – if the requested object is missing.