]> git.bitcoin.ninja Git - rust-lightning/commitdiff
try FlushFileBuffers
authorValentine Wallace <vwallace@protonmail.com>
Wed, 17 Feb 2021 20:21:22 +0000 (15:21 -0500)
committerValentine Wallace <vwallace@protonmail.com>
Wed, 17 Feb 2021 20:27:57 +0000 (15:27 -0500)
lightning-persister/Cargo.toml
lightning-persister/src/util.rs

index a6c4645545d48e4fa238c461f2c57ce8913dd77f..f9eb6c565e64c223a7b80ece6ff3aa4e5747cf9c 100644 (file)
@@ -17,7 +17,7 @@ version = "0.24"
 features = ["bitcoinconsensus"]
 
 [target.'cfg(windows)'.dependencies]
-winapi = { version = "0.3", features = ["winbase"] }
+winapi = { version = "0.3", features = ["winbase", "fileapi"] }
 
 [dev-dependencies]
 lightning = { version = "0.0.12", path = "../lightning", features = ["_test_utils"] }
index 132c20687c386dcac7169a92deb087e5f41a24ba..1cff6dca8efc85f509ed315d177761486106d6ff 100644 (file)
@@ -1,6 +1,8 @@
 
 #[cfg(target_os = "windows")]
 extern crate winapi;
+#[cfg(target_os = "windows")]
+use std::os::windows::io::IntoRawHandle;
 
 use std::fs;
 use std::path::{Path, PathBuf};
@@ -113,7 +115,9 @@ pub(crate) fn write_to_file<D: DiskWriteable>(path: String, filename: String, da
                        )});
                }
                let mut final_file = fs::File::open(filename_with_path.clone())?;
-               final_file.sync_all()?;
+               let file_handle = final_file.into_raw_handle();
+               unsafe{winapi::um::fileapi::FlushFileBuffers(file_handle);}
+               // final_file.sync_all()?;
                println!("VMW: renamed");
        }
        Ok(())