From 271042c3b01ba08389efae27be6642674acde94c Mon Sep 17 00:00:00 2001 From: Gary Yu Date: Fri, 15 Feb 2019 22:33:10 +0800 Subject: [PATCH] suppress the debug log for unexpected file report (#2574) * supress the debug log for unexpected file report in check_and_remove_files * revise according to review comments * rustfmt --- chain/src/txhashset/txhashset.rs | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/chain/src/txhashset/txhashset.rs b/chain/src/txhashset/txhashset.rs index 3520ebb2c..9be78cd27 100644 --- a/chain/src/txhashset/txhashset.rs +++ b/chain/src/txhashset/txhashset.rs @@ -1496,19 +1496,27 @@ fn check_and_remove_files(txhashset_path: &PathBuf, header: &BlockHeader) -> Res .difference(&pmmr_files_expected) .cloned() .collect(); + let mut removed = 0; if !difference.is_empty() { - debug!( - "Unexpected file(s) found in txhashset subfolder {:?}, removing.", - &subdirectory_path - ); - for diff in difference { + for diff in &difference { let diff_path = subdirectory_path.join(diff); - file::delete(diff_path.clone())?; - debug!( - "check_and_remove_files: unexpected file '{:?}' removed", - diff_path - ); + match file::delete(diff_path.clone()) { + Err(e) => error!( + "check_and_remove_files: fail to remove file '{:?}', Err: {:?}", + diff_path, e, + ), + Ok(_) => { + removed += 1; + trace!("check_and_remove_files: file '{:?}' removed", diff_path); + } + } } + debug!( + "{} tmp file(s) found in txhashset subfolder {:?}, {} removed.", + difference.len(), + &subdirectory_path, + removed, + ); } } Ok(())