From f2a5a92ff97e2dbe04ccbf7792af20011b65d11a Mon Sep 17 00:00:00 2001 From: Valentine Wallace Date: Tue, 16 Feb 2021 21:25:58 -0500 Subject: [PATCH] print perms right before rename --- lightning-persister/src/util.rs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/lightning-persister/src/util.rs b/lightning-persister/src/util.rs index e5fe0fba0..a94c7d001 100644 --- a/lightning-persister/src/util.rs +++ b/lightning-persister/src/util.rs @@ -43,15 +43,6 @@ pub(crate) fn write_to_file(path: String, filename: String, da fs::create_dir_all(path.clone())?; println!("VMW: created dir"); - println!("VMW: entries in dir:"); - let dir_perms = fs::metadata(path.clone()).unwrap().permissions(); - println!("VMW: dir perms: {:?}, readonly: {}", dir_perms, dir_perms.readonly()); - let dir = PathBuf::from(path.clone()); - for entry in fs::read_dir(dir).unwrap() { - let entry = entry.unwrap(); - let metadata = entry.metadata().unwrap(); - println!("VMW: entry in dir: {:?}, perms in entry: {:?}, readonly: {}", entry.path(), metadata.permissions(), metadata.permissions().readonly()); - } // Do a crazy dance with lots of fsync()s to be overly cautious here... // We never want to end up in a state where we've lost the old data, or end up using the // old data on power loss after we've returned. @@ -81,6 +72,16 @@ pub(crate) fn write_to_file(path: String, filename: String, da } #[cfg(target_os = "windows")] { + println!("VMW: entries in dir:"); + let dir_perms = fs::metadata(path.clone()).unwrap().permissions(); + println!("VMW: dir perms: {:?}, readonly: {}", dir_perms, dir_perms.readonly()); + let dir = PathBuf::from(path.clone()); + for entry in fs::read_dir(dir).unwrap() { + let entry = entry.unwrap(); + let metadata = entry.metadata().unwrap(); + println!("VMW: entry in dir: {:?}, perms in entry: {:?}, readonly: {}", entry.path(), metadata.permissions(), metadata.permissions().readonly()); + } + let mut dir_perms = fs::metadata(path.clone()).unwrap().permissions(); dir_perms.set_readonly(false); if let Ok(metadata) = fs::metadata(filename_with_path.clone()) { -- 2.39.5