pub fn write_atomic(target: &Path, bytes: &[u8]) -> Result<()>Expand description
Writes bytes to target atomically through rightkit_fs::AtomicWriter: a temp file in the
same directory is flushed and then renamed over the target, and the directory is synced, so
readers observe either the old or the new file, never a mix, and a failure before the rename
leaves the old file in place.
A symlink target is resolved first, so the file it points at is replaced and the link survives.
Replacing an existing file is checked against what the replacement would not keep (module docs,
“What a replacement keeps”); a refusal or a failure after the rename is an io::Error whose
inner error is the CommitError (get_ref() and downcast_ref). This function takes no
destination lock and cannot invalidate staged tokens: it is the bare writer. A staged save goes
through commit_pdf_save.