From f7e97d48dd2606b31fd613044c712a2c35bd20b5 Mon Sep 17 00:00:00 2001 From: brooks Date: Wed, 6 Sep 2023 11:04:31 -0400 Subject: [PATCH] Purges old accounts hash cache dirs --- core/src/validator.rs | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/core/src/validator.rs b/core/src/validator.rs index 80f06464bc69d5..cb40bd0ff9d4d4 100644 --- a/core/src/validator.rs +++ b/core/src/validator.rs @@ -598,10 +598,23 @@ impl Validator { timer.stop(); info!("Cleaning orphaned account snapshot directories done. {timer}"); - // The accounts hash cache dir was renamed, so cleanup the old dir if it exists. - let old_accounts_hash_cache_dir = ledger_path.join("calculate_accounts_hash_cache"); - if old_accounts_hash_cache_dir.exists() { - snapshot_utils::move_and_async_delete_path(old_accounts_hash_cache_dir); + // The accounts hash cache dir was renamed, so cleanup any old dirs that exist. + let accounts_hash_cache_path = config + .accounts_db_config + .as_ref() + .and_then(|config| config.accounts_hash_cache_path.as_ref()) + .map(PathBuf::as_path) + .unwrap_or(ledger_path); + let old_accounts_hash_cache_dirs = [ + ledger_path.join("calculate_accounts_hash_cache"), + accounts_hash_cache_path.join("full"), + accounts_hash_cache_path.join("incremental"), + accounts_hash_cache_path.join("transient"), + ]; + for old_accounts_hash_cache_dir in old_accounts_hash_cache_dirs { + if old_accounts_hash_cache_dir.exists() { + snapshot_utils::move_and_async_delete_path(old_accounts_hash_cache_dir); + } } {