synology_apm_repo.sdk.presentation.export_target module¶
The shared <dst>.part staging-file safety contract for a real,
on-disk export destination — used identically by the CLI’s export
command and the Browser’s own export worker, so the two surfaces can’t
silently disagree on when an existing destination is refused or what
happens to a partial file once a cancelled export unwinds. Both callers
already share presentation.progress’s ProgressMeter for the same
underlying ContentSource.export_to() call; this module covers the
file-lifecycle half of that same shared concern.
- synology_apm_repo.sdk.presentation.export_target.part_path_for(dst)¶
The staging path an export writes to before renaming to
dston success —<dst>.part, the one naming convention both callers share.
- synology_apm_repo.sdk.presentation.export_target.destination_available(dst, *, force)¶
Whether it’s safe to start writing toward
dst—Falseonly whendstalready exists and the caller didn’t ask to overwrite it. Checked once, up front, before any real work starts: a truncated-but-plausible-looking output file is a safety-level problem for a restore tool, not just a UX nicety.A plain synchronous call even from an async caller — one cheap
stat(), the same tier asfinalize_export()’sreplace()andresolve_cancelled_partial()’sunlink(): single filesystem metadata operations, not the bulk data path the SDK offloads withasyncio.to_thread().
- synology_apm_repo.sdk.presentation.export_target.finalize_export(part_path, dst)¶
Renames a successfully-completed
part_pathto its finaldst.
- class synology_apm_repo.sdk.presentation.export_target.CancelledPartialOutcome(kept, ever_written)¶
Bases:
objectWhat happened to
part_pathonce a cancelled export unwound — each caller renders its own message from this, since the CLI and TUI surfaces phrase it differently.
- synology_apm_repo.sdk.presentation.export_target.resolve_cancelled_partial(part_path, *, keep_partial)¶
Decides what happens to
part_pathonce a cancelled export unwinds, and performs it (deletes it unlesskeep_partial) — the one place this decision is made, rather than the CLI and TUI each hand-rolling their own (previously already diverged: the CLI deleted a cancelled export’s partial file by default, the TUI always kept it).keep_partial=Falsealways reports (and performs) removal, even whenpart_pathnever existed to begin with — “nothing left behind” holds either way, so this branch never needs to check existence at all. Onlykeep_partial=Trueneeds to distinguish “kept” from “never written,” since claiming a kept file that isn’t there would be actively misleading.