synology_apm_repo.sdk.dedup.local_file_sink module

LocalFileSink: the local-filesystem RandomAccessExportSink, plus the WorkerWriter its worker processes open for themselves.

class synology_apm_repo.sdk.dedup.local_file_sink.LocalFileDescriptor(path)

Bases: object

SinkDescriptor for a local file the parent already created.

path: str
open_writer()
class synology_apm_repo.sdk.dedup.local_file_sink.LocalFileSink(dst, *, staged, keep_partial=False)

Bases: RandomAccessExportSink

Writes to a local file through one dedicated writer thread, so writes overlap decode and may land at any offset in any order.

open creates the file at its full size (creating missing parent directories), so unwritten ranges of a sparse export read back as zero. A dense export (sparse=False) also reserves the whole file’s space there where the filesystem can (preallocated), failing in open if there isn’t room; the export then has no zero-fill to write (needs_zero_fill).

With staged=True bytes go to <dst>.part (the path property) and commit renames it to dst; with staged=False they go to dst directly. abort deletes a file nothing was written to; a file with data in it is kept when unstaged, and when staged only with keep_partial. A sink never opened, whose open failed before creating the file, or already committed, leaves the path untouched.

caps = SinkCaps(supports_sparse=True)
property path: Path
property preallocated: bool

Every byte of the destination is already reserved and reads as zero, so a dense export has no zero-fill left to write. Only meaningful after open.

async open(logical_size, *, sparse)

Creates the destination for an export of logical_size bytes.

async write_at(offset, data)
async write_zero(offset, length)
worker_target()

Where worker processes may write directly, or None when every write must go through this writer in the parent process.

note_worker_write()

Called before work is handed to worker processes writing through worker_target, whose writes never reach write_at/write_zero: the destination may now hold data, which abort must report and keep accordingly.

async commit()

Completes every handed-off write and makes the destination final.

async abort()

Releases the destination after a failure. Safe to call in any state, including before open, after commit and more than once; a repeated call returns the first call’s outcome.