From 812a5a3c537cf411d50381a6284549595b884664 Mon Sep 17 00:00:00 2001 From: Valentine Wallace Date: Wed, 17 Feb 2021 15:21:22 -0500 Subject: [PATCH] try FlushFileBuffers --- lightning-persister/Cargo.toml | 2 +- lightning-persister/src/util.rs | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) 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(()) -- 2.39.5