Unnamed repository; edit this file 'description' to name the repository.
fix: Ignore unsupported errors when trying to flush saved files to disk (#13997)
Co-authored-by: Michael Davis <[email protected]>
Charles Duffy 3 months ago
parent ac2c26e · commit f7909f1
-rw-r--r--helix-view/src/document.rs17
1 files changed, 16 insertions, 1 deletions
diff --git a/helix-view/src/document.rs b/helix-view/src/document.rs
index 42552336..4b3e1bba 100644
--- a/helix-view/src/document.rs
+++ b/helix-view/src/document.rs
@@ -1107,7 +1107,22 @@ impl Document {
let write_result: anyhow::Result<_> = async {
let mut dst = tokio::fs::File::create(&write_path).await?;
to_writer(&mut dst, encoding_with_bom_info, &text).await?;
- dst.sync_all().await?;
+ // Ignore ENOTSUP/EOPNOTSUPP (Operation not supported) errors from sync_all()
+ // This is known to occur on SMB filesystems on macOS where fsync is not supported
+ match dst.sync_all().await {
+ Ok(_) => (),
+ Err(err) if err.kind() == io::ErrorKind::Unsupported => (),
+ // Some extra OS errors are thrown on macOS for example if fsync is not
+ // available for this filesystem. NOTE: on macOS, ENOTSUP and EOPNOTSUPP are
+ // not the same code, so we need to suppress the unreachable_patterns lint on
+ // Unix generally.
+ #[allow(unreachable_patterns)]
+ #[cfg(unix)]
+ Err(err)
+ if matches!(err.raw_os_error(), Some(libc::ENOTSUP | libc::EOPNOTSUPP)) => {
+ }
+ Err(err) => return Err(err.into()),
+ }
Ok(())
}
.await;