From 24b5a78f2270790449eb2a9ff1e86ebd87cfc70b Mon Sep 17 00:00:00 2001 From: "K. Isom" Date: Mon, 19 Oct 2026 15:37:41 -0700 Subject: [PATCH] fix(store): fsync the parent directory on torn-tail truncation --- tines-store/src/log.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tines-store/src/log.rs b/tines-store/src/log.rs index 934a5755..fc87d842 100644 --- a/tines-store/src/log.rs +++ b/tines-store/src/log.rs @@ -662,10 +662,16 @@ fn ensure_parent_dir(path: &Path) -> Result<(), StoreError> { Ok(()) } -/// fsync a directory so a truncation/rewrite of a file in it is durable. +/// fsync the parent directory so a truncation/rewrite of a file in it is durable. #[cfg(unix)] fn sync_dir(path: &Path) -> Result<(), StoreError> { - let dir = File::open(path).map_err(|_| StoreError::Backend)?; + let Some(parent) = path.parent() else { + return Ok(()); + }; + if parent.as_os_str().is_empty() { + return Ok(()); + } + let dir = File::open(parent).map_err(|_| StoreError::Backend)?; dir.sync_all().map_err(|_| StoreError::Backend)?; Ok(()) }