Skip to main content

Module partial

Module partial 

Source
Expand description

The partial file an output is written to until it is finished, and how a finished one is published.

Every transactional output writes <stem>.a2partial.<ext> beside its final path and moves it into place only when it finishes. A process killed without unwinding leaves the partial behind, so liveness is decided by an exclusive advisory lock the writing export holds, which the OS drops when the process ends. An unheld partial is stale and gets replaced; a held one is refused.

The claim probes the folder with <stem>.a2probe1.<ext> and <stem>.a2probe2.<ext>: whether a file can be rewritten at an earlier offset (MP4 index, WAV header) and whether a rename without replacing works. A folder that cannot rename is refused before rendering; one that cannot seek (an in-order FUSE mount) gets a staging file in the temporary directory, copied in once finished.

A finished partial is synced, published by alpha2_os::publish_no_replace (or alpha2_os::publish_replace), and its folder synced. A finished render is never deleted: a failed publish moves it to <stem>.a2kept.<ext> (EncodeError::Publish).

When the tag would make a name too long, every sibling becomes <stem prefix>~<8 hex digits>.<tag>.<ext>, the digits a hash of the final name.

Structs§

OutputTarget
Where an output goes and what it does with a file already there.
PartialOutput
The partial file of one output from claim to publish or removal: its path, its lock, and any staging file.
PublishReport
How a finished output was published.

Enums§

ExistingOutput
What an output does with a file already at its path.
SeekNeed
Whether a container rewrites earlier bytes (MP4 index, WAV header), which the folder must allow.

Constants§

PARTIAL_OUTPUT_IN_USE
The prefix of an EncodeError::OutputInUse message, when a live export writes the partial.
PERIODIC_SYNC_BYTES
Bytes written between two syncs of an output, so the final sync flushes at most this much and a destination that stops answering is found while writing, by the stall limit.
PUBLISH_RETRY_BUDGET
How long publishing retries while another program holds the target or partial open without sharing deletion (Windows).

Functions§

partial_output_path
<stem>.a2partial.<ext> beside final_path.
png_bytes
Straight-alpha 8-bit RGBA rgba as the bytes of a PNG write_png would write.
remove_stale_partial_output
Removes a sibling partial file left by an interrupted transactional export.
write_png
Writes straight-alpha 8-bit RGBA rgba as a PNG at target, published whole or not at all like write_whole.
write_whole
Writes a whole file at target, published only once write has filled the claimed partial, with the same claim, sync and publish as a video output. A write failure removes the partial and leaves the target untouched. The target is checked before writing and again at the rename.