Expand description
Durable-file utilities shared by the binaries (internal/oak.md item 6): atomic replace-by-rename writes, a private variant for secrets, and a PID-bearing directory lock that enforces one writer process.
Ported from Oak (oak.space) cli/src/atomic_file.rs and
cli/src/workdir_lock.rs, v0.102.1 (commit 8de9515), Apache-2.0;
adapted to std errors and this workspace’s needs.
§Where this sits
docs/architecture.md is the map of the whole workspace.
This crate is the durable-file primitives — atomic writes and a working-directory lock — that the binaries share.
It depends on no other crate in this workspace.
Re-exports§
pub use atomic_file::write_atomic;pub use atomic_file::write_atomic_private;pub use workdir_lock::LockError;pub use workdir_lock::WorkdirLock;
Modules§
- atomic_
file - Atomic file replacement: write a temp file in the destination directory, sync it, rename it into place, sync the parent directory. Readers see the old contents or the new, never a torn write, and a crash between any two steps leaves the destination untouched.
- workdir_
lock - A process-level lock on a directory: a PID-bearing lock file created
with
create_new, reaped when its owner is provably dead. Guards state a single process may write, e.g. a node’s.choirdir, where two writers appending oneops.jsonlwould fork the chain.