pub struct Staged { /* private fields */ }Expand description
A private file beside a destination that parallel render workers may share (the CSS, a figure
every page uses): written or converted there, then installed by one rename,
so no reader sees a partial file and no writer touches another’s. Named
.<stem>.tmp.<pid>.<seq>.<ext> (the stem bounded), its extension kept last
for converters that read the format from it; registered with the watchdog’s exit sweep, and
removed when dropped — after an install too, since a rename onto a hard link of the same file
succeeds and leaves both names (POSIX rename(2); a destination an older binary hard-linked to
a graphics-cache entry). A name some file already holds — a killed run’s leftover, perhaps a
link to a cache entry, or a process with the same pid in another PID namespace sharing the
cache — is skipped, never written through.
Implementations§
Source§impl Staged
impl Staged
Sourcepub fn beside(dest: &Path) -> Self
pub fn beside(dest: &Path) -> Self
A fresh private path beside dest that no file holds, for a converter to write (nothing
is created).
Sourcepub fn alias(src: &Path) -> Result<Self>
pub fn alias(src: &Path) -> Result<Self>
A hard link to src, or a copy, under a short name in the temporary directory, lx.<pid>.<seq>.<ext> (the
extension kept for converters that read the format from it): src’s bytes where its own path is out of reach.
pub fn path(&self) -> &Path
Sourcepub fn install(self, dest: &Path) -> Result<()>
pub fn install(self, dest: &Path) -> Result<()>
Install the staged file as dest by rename. When the rename fails (Windows’
MoveFileExW refuses a file another worker holds open) but dest already holds these very
bytes, a sibling installed the same output and the install stands; the bytes are compared
before the temp is removed, so a stale file of the same length is never taken for it.