Skip to main content

Module writer

Module writer 

Source
Expand description

Crash-safe persistence (DESIGN.md §7).

Never truncate-then-write: every overwrite goes through a temp file in the same directory + fs::rename, so a crash mid-write leaves either the old or the new content, never neither (invariant #6). Backups copy the original bytes before the rename, mirroring the tree structure under --backup-dir.

Functions§

atomic_write
Atomically replace path with bytes.
backup_original
Copy the original bytes of path into backup_dir, mirroring the tree structure relative to root.