buildgrid.server.cas.storage.disk module

DiskStorage

A CAS storage provider that stores files as blobs on disk.

class buildgrid.server.cas.storage.disk.DiskStorage(path: str)

Bases: StorageABC

has_blob(digest: Digest) bool

Return True if the blob with the given instance/digest exists.

get_blob(digest: Digest) IO[bytes] | None

Return a file-like object containing the blob. Most implementations will read the entire file into memory and return a BytesIO object. Eventually this should be corrected to handle files which cannot fit into memory.

The file-like object must be readable and seekable.

If the blob isn’t present in storage, return None.

bulk_read_blobs(digests: List[Digest]) Dict[str, IO[bytes]]

Given an iterable container of digests, return a {hash: file-like object} dictionary corresponding to the blobs represented by the input digests.

Each file-like object must be readable and seekable.

delete_blob(digest: Digest) None

Delete the blob from storage if it’s present.

begin_write(digest: Digest) IO[bytes]

Return a file-like object to which a blob’s contents could be written.

commit_write(digest: Digest, write_session: IO[bytes]) None

Commit the write operation. write_session must be an object returned by begin_write.

The storage object is not responsible for verifying that the data written to the write_session actually matches the digest. The caller must do that.