From 098076f5cab81a54335330993842fc0831e1ca65 Mon Sep 17 00:00:00 2001 From: Brooks Date: Mon, 22 Jan 2024 19:47:58 -0500 Subject: [PATCH] Uses accounts run and snapshot dir constants (#34879) --- runtime/src/snapshot_utils.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/runtime/src/snapshot_utils.rs b/runtime/src/snapshot_utils.rs index 371c12512a67a1..f20f5297ffce6b 100644 --- a/runtime/src/snapshot_utils.rs +++ b/runtime/src/snapshot_utils.rs @@ -24,7 +24,7 @@ use { append_vec::AppendVec, hardened_unpack::{self, ParallelSelector, UnpackError}, shared_buffer_reader::{SharedBuffer, SharedBufferReader}, - utils::delete_contents_of_path, + utils::{delete_contents_of_path, ACCOUNTS_RUN_DIR, ACCOUNTS_SNAPSHOT_DIR}, }, solana_measure::{measure, measure::Measure}, solana_sdk::{clock::Slot, hash::Hash}, @@ -1175,7 +1175,7 @@ fn get_account_path_from_appendvec_path(appendvec_path: &Path) -> Option/run/. // When generating the bank snapshot directory, they are hardlinked to /snapshot// - if run_file_name != "run" { + if run_file_name != ACCOUNTS_RUN_DIR { error!( "The account path {} does not have run/ as its immediate parent directory.", run_path.display() @@ -1198,7 +1198,9 @@ fn get_snapshot_accounts_hardlink_dir( GetSnapshotAccountsHardLinkDirError::GetAccountPath(appendvec_path.to_path_buf()) })?; - let snapshot_hardlink_dir = account_path.join("snapshot").join(bank_slot.to_string()); + let snapshot_hardlink_dir = account_path + .join(ACCOUNTS_SNAPSHOT_DIR) + .join(bank_slot.to_string()); // Use the hashset to track, to avoid checking the file system. Only set up the hardlink directory // and the symlink to it at the first time of seeing the account_path. @@ -1539,7 +1541,7 @@ pub fn rebuild_storages_from_snapshot_dir( .ok_or_else(|| SnapshotError::InvalidAccountPath(account_snapshot_path.clone()))? .parent() .ok_or_else(|| SnapshotError::InvalidAccountPath(account_snapshot_path.clone()))? - .join("run"); + .join(ACCOUNTS_RUN_DIR); if !account_run_paths.contains(&account_run_path) { // The appendvec from the bank snapshot storage does not match any of the provided account_paths set. // The accout paths have changed so the snapshot is no longer usable.