synology_apm_repo.sdk.api.export module

run_export: the one way to export a restorable unit’s content to an ExportSink.

type synology_apm_repo.sdk.api.export.ExportProgressCallback = Callable[[int, int], Awaitable[None]]

Receives an export’s (done, total) byte counts as data is written.

async synology_apm_repo.sdk.api.export.run_export(content, sink, *, sparse=True, progress=None, tuning=None)

Exports content into sink: opens the sink at the content’s size, writes every byte into it, then commits it. On any failure — cancellation included — the sink is aborted and the error re-raised; call the sink’s abort() again (idempotent) for its AbortOutcome.

A sink with a segment_size is fed one segment at a time, each written in full and then completed before the next is requested, so the sink decides when the export may go on.

Parameters:
  • content (ContentSource) – The content to export.

  • sink (ExportSink) – The destination; a fresh one, not yet opened.

  • sparse (bool) – Leave ZERO/HOLE ranges unwritten where the sink allows it.

  • progress (ExportProgressCallback | None) – Receives (done, total) byte counts as data is written; total is content.planned_bytes over the whole content, which can be less than its size (dedup-backed content counts only DATA bytes).

  • tuning (ExportTuning | None) – How dedup-backed content decodes (default ExportTuning(): in this process, several reads at once); ignored by other content.

Returns:

What was written, and how much of the content was holes or zeros.

Raises:

ValueError – The content’s size is unknown even after a read, or the sink’s segment_size is not a positive multiple of 4096.

Return type:

ExportResult