Skip to main content

write_file_atomic

Function write_file_atomic 

Source
pub fn write_file_atomic(tmp: &Path, path: &Path, bytes: &[u8]) -> Result<()>
Expand description

Replace path with bytes atomically and durably through real file I/O: write tmp, sync it, rename it over path, then sync the parent directory.

This is the entry point for files outside a partition log, such as the controller’s quorum-state file and its metadata checkpoints, which have no fault-injection seam of their own.

§Errors

Returns the first create, write, sync or rename error.