pub fn atomic_write_file<F, E>(file_path: &Path, write_fn: F) -> Result<()>
Expand description
Writes atomically to file.
- Creates a temporary file with a
.tmp
extension in the same file directory. - Writes content with
write_fn
. - Fsyncs the temp file to disk.
- Renames the temp file to the target path.
- Fsyncs the file directory.
Atomic writes are hard: