diff --git a/runtime/src/serde_snapshot.rs b/runtime/src/serde_snapshot.rs index ef5cf7c5569dc6..8e2bf52836cbdb 100644 --- a/runtime/src/serde_snapshot.rs +++ b/runtime/src/serde_snapshot.rs @@ -412,8 +412,7 @@ pub fn reserialize_bank_with_new_accounts_hash( ) -> bool { let bank_post = snapshot_utils::get_bank_snapshots_dir(bank_snapshots_dir, slot); let bank_post = bank_post.join(snapshot_utils::get_snapshot_file_name(slot)); - let mut bank_pre = bank_post.clone(); - bank_pre.set_extension(BANK_SNAPSHOT_PRE_FILENAME_EXTENSION); + let bank_pre = bank_post.with_extension(BANK_SNAPSHOT_PRE_FILENAME_EXTENSION); let mut found = false; { diff --git a/runtime/src/serde_snapshot/tests.rs b/runtime/src/serde_snapshot/tests.rs index fd09b7a180b778..ccef6fbe445532 100644 --- a/runtime/src/serde_snapshot/tests.rs +++ b/runtime/src/serde_snapshot/tests.rs @@ -311,11 +311,10 @@ fn test_bank_serialize_style( let temp_dir = TempDir::new().unwrap(); let slot_dir = temp_dir.path().join(slot.to_string()); let post_path = slot_dir.join(slot.to_string()); - let mut pre_path = post_path.clone(); - pre_path.set_extension(BANK_SNAPSHOT_PRE_FILENAME_EXTENSION); + let pre_path = post_path.with_extension(BANK_SNAPSHOT_PRE_FILENAME_EXTENSION); std::fs::create_dir(&slot_dir).unwrap(); { - let mut f = std::fs::File::create(&pre_path).unwrap(); + let mut f = std::fs::File::create(pre_path).unwrap(); f.write_all(&buf).unwrap(); } diff --git a/runtime/src/snapshot_utils.rs b/runtime/src/snapshot_utils.rs index 58b525e2603b0b..ff43813aa69afe 100644 --- a/runtime/src/snapshot_utils.rs +++ b/runtime/src/snapshot_utils.rs @@ -165,8 +165,8 @@ impl BankSnapshotInfo { // BankSnapshotPost file let bank_snapshot_dir = get_bank_snapshots_dir(&bank_snapshots_dir, slot); let bank_snapshot_post_path = bank_snapshot_dir.join(get_snapshot_file_name(slot)); - let mut bank_snapshot_pre_path = bank_snapshot_post_path.clone(); - bank_snapshot_pre_path.set_extension(BANK_SNAPSHOT_PRE_FILENAME_EXTENSION); + let bank_snapshot_pre_path = + bank_snapshot_post_path.with_extension(BANK_SNAPSHOT_PRE_FILENAME_EXTENSION); if bank_snapshot_pre_path.is_file() { return Some(BankSnapshotInfo { @@ -991,8 +991,9 @@ pub fn add_bank_snapshot( fs::create_dir_all(&bank_snapshot_dir)?; // the bank snapshot is stored as bank_snapshots_dir/slot/slot.BANK_SNAPSHOT_PRE_FILENAME_EXTENSION - let mut bank_snapshot_path = bank_snapshot_dir.join(get_snapshot_file_name(slot)); - bank_snapshot_path.set_extension(BANK_SNAPSHOT_PRE_FILENAME_EXTENSION); + let bank_snapshot_path = bank_snapshot_dir + .join(get_snapshot_file_name(slot)) + .with_extension(BANK_SNAPSHOT_PRE_FILENAME_EXTENSION); info!( "Creating bank snapshot for slot {}, path: {}", @@ -2318,13 +2319,9 @@ pub fn verify_snapshot_archive( ) .unwrap(); - // Bank snapshots may contain an accounts directory of hard linked append vecs, - // which must be removed in order for the directory comparison with the snapshot - // archive (below) to succeed. - let accounts_hardlinks_dir = snapshot_slot_dir.join("accounts_hardlinks"); if accounts_hardlinks_dir.is_dir() { - // This directory contain symlinks to all accounts snapshot directories. + // This directory contain symlinks to all /snapshot/ directories. // They should all be removed. for entry in fs::read_dir(&accounts_hardlinks_dir).unwrap() { let dst_path = fs::read_link(entry.unwrap().path()).unwrap(); @@ -2332,16 +2329,6 @@ pub fn verify_snapshot_archive( } std::fs::remove_dir_all(accounts_hardlinks_dir).unwrap(); } - - // Remove the new accounts/ to be consistent with the - // old archive structure. - let accounts_path = snapshot_slot_dir.join("accounts"); - if accounts_path.is_dir() { - // Do not use the async move_and_async_delete_path because the assert below - // requires the job to be done. - // This is for test only, so the performance is not an issue. - std::fs::remove_dir_all(accounts_path).unwrap(); - } } assert!(!dir_diff::is_different(&snapshots_to_verify, unpacked_snapshots).unwrap());