]> git.bitcoin.ninja Git - rust-lightning/commitdiff
ReplaceFileW w/ backup
authorValentine Wallace <vwallace@protonmail.com>
Wed, 17 Feb 2021 03:12:30 +0000 (22:12 -0500)
committerValentine Wallace <vwallace@protonmail.com>
Wed, 17 Feb 2021 03:12:30 +0000 (22:12 -0500)
lightning-persister/src/util.rs

index 9dd9ddb9be20a42caf805831eef2ad0f4b209797..ac923d6857670e3b4b8559e357733d80b6d56d26 100644 (file)
@@ -100,8 +100,9 @@ pub(crate) fn write_to_file<D: DiskWriteable>(path: String, filename: String, da
                //      path_to_windows_str(src).as_ptr(), path_to_windows_str(dst).as_ptr(),
                //      winapi::um::winbase::MOVEFILE_WRITE_THROUGH | winapi::um::winbase::MOVEFILE_REPLACE_EXISTING
                // )});
+               let backup_filepath = format!("{}.backup", filename_with_path.clone());
                call!(unsafe {winapi::um::winbase::ReplaceFileW(
-                       path_to_windows_str(src).as_ptr(), path_to_windows_str(dst).as_ptr(), std::ptr::null,
+                       path_to_windows_str(src).as_ptr(), path_to_windows_str(dst).as_ptr(), path_to_windows_str(backup_filepath).as_ptr(),
                        winapi::um::winbase::MOVEFILE_WRITE_THROUGH | winapi::um::winbase::MOVEFILE_REPLACE_EXISTING, std::ptr::null, std::ptr::null
                )});
                println!("VMW: renamed");