diff --git a/runtime/src/snapshot_package.rs b/runtime/src/snapshot_package.rs index d0516129fbd78b..c1c5513ac35388 100644 --- a/runtime/src/snapshot_package.rs +++ b/runtime/src/snapshot_package.rs @@ -93,12 +93,9 @@ impl AccountsPackage { fs::create_dir_all(&snapshot_hardlink_dir)?; let snapshot_path = bank_snapshot_info.snapshot_path(); let file_name = snapshot_utils::path_to_file_name_str(&snapshot_path)?; - fs::hard_link( - bank_snapshot_info.snapshot_path(), - snapshot_hardlink_dir.join(file_name), - )?; + fs::hard_link(&snapshot_path, snapshot_hardlink_dir.join(file_name))?; let status_cache_path = bank_snapshot_info - .bank_snapshot_dir + .snapshot_dir .join(SNAPSHOT_STATUS_CACHE_FILENAME); let status_cache_file_name = snapshot_utils::path_to_file_name_str(&status_cache_path)?; fs::hard_link( diff --git a/runtime/src/snapshot_utils.rs b/runtime/src/snapshot_utils.rs index 29664496f7f837..39b4f65573e2c2 100644 --- a/runtime/src/snapshot_utils.rs +++ b/runtime/src/snapshot_utils.rs @@ -139,7 +139,7 @@ pub struct BankSnapshotInfo { /// Type of the snapshot pub snapshot_type: BankSnapshotType, /// Path to the bank snapshot directory - pub bank_snapshot_dir: PathBuf, + pub snapshot_dir: PathBuf, } impl PartialOrd for BankSnapshotInfo { @@ -158,7 +158,7 @@ impl Ord for BankSnapshotInfo { impl BankSnapshotInfo { pub fn new_from_dir( bank_snapshots_dir: impl AsRef, - slot: u64, + slot: Slot, ) -> Option { // check this directory to see if there is a BankSnapshotPre and/or // BankSnapshotPost file @@ -171,7 +171,7 @@ impl BankSnapshotInfo { return Some(BankSnapshotInfo { slot, snapshot_type: BankSnapshotType::Pre, - bank_snapshot_dir, + snapshot_dir: bank_snapshot_dir, }); } @@ -179,7 +179,7 @@ impl BankSnapshotInfo { return Some(BankSnapshotInfo { slot, snapshot_type: BankSnapshotType::Post, - bank_snapshot_dir, + snapshot_dir: bank_snapshot_dir, }); } @@ -187,9 +187,7 @@ impl BankSnapshotInfo { } pub fn snapshot_path(&self) -> PathBuf { - let mut bank_snapshot_path = self - .bank_snapshot_dir - .join(get_snapshot_file_name(self.slot)); + let mut bank_snapshot_path = self.snapshot_dir.join(get_snapshot_file_name(self.slot)); let ext = match self.snapshot_type { BankSnapshotType::Pre => BANK_SNAPSHOT_PRE_FILENAME_EXTENSION, @@ -949,7 +947,7 @@ pub fn add_bank_snapshot( Ok(BankSnapshotInfo { slot, snapshot_type: BankSnapshotType::Pre, - bank_snapshot_dir, + snapshot_dir: bank_snapshot_dir, }) } @@ -2237,7 +2235,7 @@ pub fn purge_old_bank_snapshots(bank_snapshots_dir: impl AsRef) { if r.is_err() { warn!( "Couldn't remove bank snapshot at: {}", - bank_snapshot.bank_snapshot_dir.display() + bank_snapshot.snapshot_dir.display() ); } })