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:
objectSinkDescriptorfor a local file the parent already created.- open_writer()¶
- class synology_apm_repo.sdk.dedup.local_file_sink.LocalFileSink(dst, *, staged, keep_partial=False)¶
Bases:
RandomAccessExportSinkWrites to a local file through one dedicated writer thread, so writes overlap decode and may land at any offset in any order.
opencreates 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 inopenif there isn’t room; the export then has no zero-fill to write (needs_zero_fill).With
staged=Truebytes go to<dst>.part(thepathproperty) andcommitrenames it todst; withstaged=Falsethey go todstdirectly.abortdeletes a file nothing was written to; a file with data in it is kept when unstaged, and when staged only withkeep_partial. A sink never opened, whoseopenfailed before creating the file, or already committed, leaves the path untouched.- caps = SinkCaps(supports_sparse=True)¶
- 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_sizebytes.
- async write_at(offset, data)¶
- async write_zero(offset, length)¶
- worker_target()¶
Where worker processes may write directly, or
Nonewhen 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 reachwrite_at/write_zero: the destination may now hold data, whichabortmust 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, aftercommitand more than once; a repeated call returns the first call’s outcome.