Save: a network drive on macOS that refuses the full flush gets a plain fsync (fixes #1620)

This commit is contained in:
Marco Arnulfo
2026-10-13 12:58:04 +07:00
committed by bflatastic
parent 63686e659e
commit 5e8581e42f
5 changed files with 101 additions and 5 deletions
+1 -1
View File
@@ -794,7 +794,7 @@ pub(crate) fn write_new_file(path: &str, bytes: &[u8]) -> Result<()> {
may_write(path)?;
let err = |e: std::io::Error| EngineError::Other(format!("{path}: {e}"));
let mut f = std::fs::OpenOptions::new().write(true).create_new(true).open(path).map_err(err)?;
let written = f.write_all(bytes).and_then(|()| f.sync_all());
let written = f.write_all(bytes).and_then(|()| vectorcraft_format::sync_file(&f));
drop(f);
written.map_err(|e| {
// Best effort: the partly written file is all there is to clean up.