swh.objstorage.backends.winery package#

Subpackages#

Submodules#

Module contents#

class swh.objstorage.backends.winery.WineryObjStorage(database: Database, shards: Shards, shards_pool: ShardsPool, throttler: Throttler, packer: Packer | None = None, readonly: bool = False, allow_delete: bool = False, name: str = 'winery')[source]#

Bases: ObjStorage

primary_hash: Literal['sha1', 'sha256'] = 'sha256'#
name: str = 'winery'#

Default objstorage name; can be overloaded at instantiation time giving a ‘name’ argument to the constructor

get(obj_id: HashDict) bytes[source]#

Retrieve the content of a given object.

Parameters:

obj_id – object id.

Returns:

the content of the requested object as bytes.

Raises:

ObjNotFoundError – if the requested object is missing.

check_config(*, check_write: bool) bool[source]#

Check whether the object storage is properly configured.

Parameters:
  • check_write (bool) – if True, check if writes to the object storage

  • succeed. (can)

Returns:

True if the configuration check worked, False if ‘check_write’ is True and the object storage is actually read only, and an exception if the check failed.

add(content: bytes, obj_id: HashDict, check_presence: bool = True) None[source]#

Add a new object to the object storage.

Parameters:
  • content – object’s raw content to add in storage.

  • obj_id – dict of checksums.

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

delete(obj_id: HashDict)[source]#

Delete an object.

Parameters:

obj_id – object identifier.

Raises:

ObjNotFoundError – if the requested object is missing.

on_shutdown()[source]#
swh.objstorage.backends.winery.get_datastore(**cfg)[source]#