Skip to main content

Module atomic_file

Module atomic_file 

Source
Expand description

Atomic cache-file replacement, shared by the extraction cache and the graph cache so concurrent fallow processes never interleave a write. Atomic replacement of a cache file.

The extraction cache and the graph cache both live in .fallow/, and more than one fallow process can write there at the same time: an editor server beside a CLI run, or a pre-commit hook beside an editor. A fixed temp name (cache.bin.tmp) let those writers truncate and interleave bytes in one shared file, so the renamed result could hold parts of two payloads, and a writer whose temp file another writer had already renamed failed outright. Each write here gets its own uniquely named temp file in the target directory, so the rename always moves one complete payload into place.

Functionsยง

write_atomic
Replace path with data atomically.