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
This commit is contained in:
Gary Yu 2019-02-15 22:33:10 +08:00 committed by Antioch Peverell
parent 99494c6fa6
commit 271042c3b0

View file

@ -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(())