From 86a2ac6fa2099629cf3194201706f429728849be Mon Sep 17 00:00:00 2001 From: Alex Zammit <56401306+kaxxa123@users.noreply.github.com> Date: Wed, 4 Sep 2024 22:03:04 +0200 Subject: [PATCH] fix: nippy jar error access is denied. os error 5 (#9747) (#10672) Co-authored-by: joshieDo <93316087+joshieDo@users.noreply.github.com> --- crates/storage/nippy-jar/src/lib.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/crates/storage/nippy-jar/src/lib.rs b/crates/storage/nippy-jar/src/lib.rs index 2f7a411ab7..20c06c5a88 100644 --- a/crates/storage/nippy-jar/src/lib.rs +++ b/crates/storage/nippy-jar/src/lib.rs @@ -21,6 +21,11 @@ use std::{ ops::Range, path::{Path, PathBuf}, }; + +// Windows specific extension for std::fs +#[cfg(windows)] +use std::os::windows::prelude::OpenOptionsExt; + use tracing::*; pub mod compression; @@ -261,6 +266,16 @@ impl NippyJar { // fsync() dir if let Some(parent) = tmp_path.parent() { + //custom_flags() is only available on Windows + #[cfg(windows)] + OpenOptions::new() + .read(true) + .write(true) + .custom_flags(0x02000000) // FILE_FLAG_BACKUP_SEMANTICS + .open(parent)? + .sync_all()?; + + #[cfg(not(windows))] OpenOptions::new().read(true).open(parent)?.sync_all()?; } Ok(())