Expand description
Cross-process safety for shared files: a lock compatible with
proper-lockfile, which pi uses for auth.json, settings.json and
trust.json, and an atomic replacement of a file’s contents. The lock is a
<file>.lock directory, and one whose modification time is older than the
stale period may be taken over. A lock taken with FileLock::acquire
keeps its modification time fresh while held, as proper-lockfile does.
Structs§
- File
Lock - A held lock. Dropping it releases the lock.
Enums§
- Lock
Error - Why the lock could not be taken.
Functions§
- write_
atomic - Replaces
path’s contents so that readers see the old or the new bytes, never a partial file: writes a temporary file beside it, flushes it to disk and renames it overpath. An existing file keeps its permissions, and a new one getscreate_mode(Unix, less the umask). A symbolic link keeps pointing at its target, which receives the contents. On error the file is unchanged.