Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Replaces fs-err in verify_snapshot_archive() #34887

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions runtime/src/snapshot_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2093,7 +2093,7 @@ pub fn verify_snapshot_archive(
// collect all the appendvecs in account_paths/<slot>/snapshot/ into one directory for later comparison.
let storages_to_verify = unpack_dir.join("storages_to_verify");
// Create the directory if it doesn't exist
fs_err::create_dir_all(&storages_to_verify).unwrap();
fs::create_dir_all(&storages_to_verify).unwrap();

let slot = slot.to_string();
let snapshot_slot_dir = snapshots_to_verify.as_ref().join(&slot);
Expand All @@ -2103,8 +2103,8 @@ pub fn verify_snapshot_archive(
let p1 = snapshots_to_verify.as_ref().join(&slot).join(&slot);
let p2 = unpacked_snapshots.join(&slot).join(&slot);
assert!(crate::serde_snapshot::compare_two_serialized_banks(&p1, &p2).unwrap());
fs_err::remove_file(p1).unwrap();
fs_err::remove_file(p2).unwrap();
fs::remove_file(p1).unwrap();
fs::remove_file(p2).unwrap();
}

// The new the status_cache file is inside the slot directory together with the snapshot file.
Expand All @@ -2117,7 +2117,7 @@ pub fn verify_snapshot_archive(
let new_unpacked_status_cache_file = unpacked_snapshots
.join(&slot)
.join(SNAPSHOT_STATUS_CACHE_FILENAME);
fs_err::rename(
fs::rename(
existing_unpacked_status_cache_file,
new_unpacked_status_cache_file,
)
Expand All @@ -2126,26 +2126,26 @@ pub fn verify_snapshot_archive(
let accounts_hardlinks_dir = snapshot_slot_dir.join(SNAPSHOT_ACCOUNTS_HARDLINKS);
if accounts_hardlinks_dir.is_dir() {
// This directory contain symlinks to all <account_path>/snapshot/<slot> directories.
for entry in fs_err::read_dir(&accounts_hardlinks_dir).unwrap() {
let link_dst_path = fs_err::read_link(entry.unwrap().path()).unwrap();
for entry in fs::read_dir(&accounts_hardlinks_dir).unwrap() {
let link_dst_path = fs::read_link(entry.unwrap().path()).unwrap();
// Copy all the files in dst_path into the storages_to_verify directory.
for entry in fs_err::read_dir(&link_dst_path).unwrap() {
for entry in fs::read_dir(&link_dst_path).unwrap() {
let src_path = entry.unwrap().path();
let dst_path = storages_to_verify.join(src_path.file_name().unwrap());
fs_err::copy(src_path, dst_path).unwrap();
fs::copy(src_path, dst_path).unwrap();
}
}
fs_err::remove_dir_all(accounts_hardlinks_dir).unwrap();
fs::remove_dir_all(accounts_hardlinks_dir).unwrap();
}

let version_path = snapshot_slot_dir.join(SNAPSHOT_VERSION_FILENAME);
if version_path.is_file() {
fs_err::remove_file(version_path).unwrap();
fs::remove_file(version_path).unwrap();
}

let state_complete_path = snapshot_slot_dir.join(SNAPSHOT_STATE_COMPLETE_FILENAME);
if state_complete_path.is_file() {
fs_err::remove_file(state_complete_path).unwrap();
fs::remove_file(state_complete_path).unwrap();
}

assert!(!dir_diff::is_different(&snapshots_to_verify, unpacked_snapshots).unwrap());
Expand All @@ -2155,7 +2155,7 @@ pub fn verify_snapshot_archive(
// Remove the empty "accounts" directory for the directory comparison below.
// In some test cases the directory to compare do not come from unarchiving.
// Ignore the error when this directory does not exist.
_ = fs_err::remove_dir(unpack_account_dir.join("accounts"));
_ = fs::remove_dir(unpack_account_dir.join("accounts"));
// Check the account entries are the same
assert!(!dir_diff::is_different(&storages_to_verify, unpack_account_dir).unwrap());
}
Expand Down