Expand description
Facade: atomic-write mechanics live in the lean-ctx-fs crate.
Enums§
- Store
Read Error - Why a store file could not be read safely.
Functions§
- in_
place_ overwrite - In-place overwrite of an existing file inode (
O_WRONLY|O_TRUNC, plusO_NOFOLLOWon Unix). Works when the parent directory is read-only but the file itself is writable. Not crash-atomic — used only as a fallback when the atomic path is impossible. - is_
orphaned_ temp - Whether
nameis a temp file of these atomic writes that a crash left behind: its writer is gone, or it is older than an hour (#958). - is_
readonly_ dir_ error - True for errors that mean “this directory won’t accept create/rename” even
though the target file may be writable:
EROFS(read-only fs) plusEACCES/EPERM(directory write denied). - read_
store_ file - Read a file of a local content store (archive, tee) for the model without following links out of the store and without a check-then-open race.
- replace_
file - Atomically move a fully written
tmpoverpath:rename(2)on Unix,windows_replace(with its bounded retry of a held target) on Windows.tmpis left in place on failure; the caller removes it. - sync_
directory - Make a preceding
rename/create/removeindirdurable, reporting failure. On Unix this fsyncs the directory. Windows cannot flush a directory through a plainFile::open(it fails withERROR_ACCESS_DENIED); NTFS journals directory metadata itself, so only the directory’s existence is verified there — the same contract as the#[cfg(unix)]sync sites elsewhere in the crate. - try_
atomic_ write - Durable, crash-atomic write: a temp file in the same directory as
pathfollowed byrenameover the target. Requires write permission on the parent directory; the read-only-directory fallback is handled bywrite_bytes_with_fallback. - try_
atomic_ write_ if try_atomic_writewith a last word for the caller:may_commitis asked once the new content is fully staged and synced, immediately before the replace. Onfalsethe staged file is removed,pathis untouched and the error kind isTimedOut. Everything slow (cleanup, create, write, sync) lies before that question; after it only the replace itself follows — which on Windows may retry a held target for about a second.- try_
atomic_ write_ unswept try_atomic_writewithout the sweep for orphaned temps: for a directory of very many files (the gateway evidence store) where listing it on every write would cost more than the write, and whose owner removes stale temps itself (is_orphaned_temp).- write_
bytes_ with_ fallback - Atomic write with the read-only-directory in-place fallback (#459). Tries the
crash-atomic temp+rename first; if that fails because the directory is
read-only/permission-denied but an existing file inode is writable, overwrite
it in place.
permissions, when given, is applied to the written file.