From: Valentine Wallace Date: Wed, 17 Feb 2021 20:21:22 +0000 (-0500) Subject: try FlushFileBuffers X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=812a5a3c537cf411d50381a6284549595b884664;p=rust-lightning try FlushFileBuffers --- diff --git a/lightning-persister/Cargo.toml b/lightning-persister/Cargo.toml index a6c464554..f9eb6c565 100644 --- a/lightning-persister/Cargo.toml +++ b/lightning-persister/Cargo.toml @@ -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"] } diff --git a/lightning-persister/src/util.rs b/lightning-persister/src/util.rs index 132c20687..1cff6dca8 100644 --- a/lightning-persister/src/util.rs +++ b/lightning-persister/src/util.rs @@ -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(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(())