In ledger-tool delete the account files in the async way (#27622)

* In ledger-tool delete the account files in the async way

* format changes by ./cargo nightly fmt --all
This commit is contained in:
Xiang Zhu 2022-09-07 14:35:06 -07:00 committed by GitHub
parent 6a322de845
commit 4308c300b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 9 deletions

View File

@ -2049,7 +2049,7 @@ fn get_stake_percent_in_gossip(bank: &Bank, cluster_info: &ClusterInfo, log: boo
/// If the process is killed and the deleting process is not done,
/// the leftover path will be deleted in the next process life, so
/// there is no file space leaking.
fn move_and_async_delete_path(path: impl AsRef<Path> + Copy) {
pub fn move_and_async_delete_path(path: impl AsRef<Path> + Copy) {
let mut path_delete = PathBuf::new();
path_delete.push(path);
path_delete.set_file_name(format!(

View File

@ -19,7 +19,9 @@ use {
is_parsable, is_pow2, is_pubkey, is_pubkey_or_keypair, is_slot, is_valid_percentage,
},
},
solana_core::system_monitor_service::SystemMonitorService,
solana_core::{
system_monitor_service::SystemMonitorService, validator::move_and_async_delete_path,
},
solana_entry::entry::Entry,
solana_geyser_plugin_manager::geyser_plugin_service::GeyserPluginService,
solana_ledger::{
@ -1053,13 +1055,10 @@ fn load_bank_forks(
if non_primary_accounts_path.exists() {
info!("Clearing {:?}", non_primary_accounts_path);
if let Err(err) = std::fs::remove_dir_all(&non_primary_accounts_path) {
eprintln!(
"error deleting accounts path {:?}: {}",
non_primary_accounts_path, err
);
exit(1);
}
let mut measure_time = Measure::start("clean_non_primary_accounts_paths");
move_and_async_delete_path(&non_primary_accounts_path);
measure_time.stop();
info!("done. {}", measure_time);
}
vec![non_primary_accounts_path]