diff --git a/runtime/src/accounts_db.rs b/runtime/src/accounts_db.rs index 6f28d52278..aaf96d0534 100644 --- a/runtime/src/accounts_db.rs +++ b/runtime/src/accounts_db.rs @@ -380,8 +380,8 @@ pub struct AccountStorageEntry { impl AccountStorageEntry { pub fn new(path: &Path, slot: Slot, id: usize, file_size: u64) -> Self { - let tail = AppendVec::new_relative_path(slot, id); - let path = Path::new(path).join(&tail); + let tail = AppendVec::file_name(slot, id); + let path = Path::new(path).join(tail); let accounts = AppendVec::new(&path, true, file_size as usize); Self { @@ -543,10 +543,6 @@ impl AccountStorageEntry { count } - pub fn get_relative_path(&self) -> Option { - AppendVec::get_relative_path(self.accounts.get_path()) - } - pub fn get_path(&self) -> PathBuf { self.accounts.get_path() } diff --git a/runtime/src/append_vec.rs b/runtime/src/append_vec.rs index bf57131f0a..f14874b90f 100644 --- a/runtime/src/append_vec.rs +++ b/runtime/src/append_vec.rs @@ -279,13 +279,8 @@ impl AppendVec { self.file_size } - // Get the file path relative to the top level accounts directory - pub fn get_relative_path>(append_vec_path: P) -> Option { - append_vec_path.as_ref().file_name().map(PathBuf::from) - } - - pub fn new_relative_path(slot: Slot, id: usize) -> PathBuf { - PathBuf::from(&format!("{}.{}", slot, id)) + pub fn file_name(slot: Slot, id: usize) -> String { + format!("{}.{}", slot, id) } pub fn new_from_file>(path: P, current_len: usize) -> io::Result<(Self, usize)> { @@ -720,16 +715,6 @@ pub mod tests { ); } - #[test] - fn test_relative_path() { - let relative_path = AppendVec::new_relative_path(0, 2); - let full_path = Path::new("/tmp").join(&relative_path); - assert_eq!( - relative_path, - AppendVec::get_relative_path(full_path).unwrap() - ); - } - #[test] fn test_new_from_file_crafted_zero_lamport_account() { let file = get_append_vec_path("test_append"); diff --git a/runtime/src/serde_snapshot.rs b/runtime/src/serde_snapshot.rs index ef952fb445..ae88716367 100644 --- a/runtime/src/serde_snapshot.rs +++ b/runtime/src/serde_snapshot.rs @@ -313,8 +313,7 @@ where // Move the corresponding AppendVec from the snapshot into the directory pointed // at by `local_dir` - let append_vec_relative_path = - AppendVec::new_relative_path(slot, storage_entry.id()); + let append_vec_relative_path = AppendVec::file_name(slot, storage_entry.id()); let append_vec_abs_path = stream_append_vecs_path .as_ref() .join(&append_vec_relative_path); diff --git a/runtime/src/serde_snapshot/tests.rs b/runtime/src/serde_snapshot/tests.rs index 2e569fbd3c..efb5d4a3f2 100644 --- a/runtime/src/serde_snapshot/tests.rs +++ b/runtime/src/serde_snapshot/tests.rs @@ -27,7 +27,7 @@ fn copy_append_vecs>( let storage_entries = accounts_db.get_snapshot_storages(Slot::max_value()); for storage in storage_entries.iter().flatten() { let storage_path = storage.get_path(); - let output_path = output_dir.as_ref().join(AppendVec::new_relative_path( + let output_path = output_dir.as_ref().join(AppendVec::file_name( storage.slot(), storage.append_vec_id(), )); diff --git a/runtime/src/snapshot_utils.rs b/runtime/src/snapshot_utils.rs index c4d01ef6a8..6204cbd73b 100644 --- a/runtime/src/snapshot_utils.rs +++ b/runtime/src/snapshot_utils.rs @@ -271,11 +271,10 @@ pub fn archive_snapshot_package(snapshot_package: &AccountsPackage) -> Result<() for storage in snapshot_package.storages.iter().flatten() { storage.flush()?; let storage_path = storage.get_path(); - let output_path = - staging_accounts_dir.join(crate::append_vec::AppendVec::new_relative_path( - storage.slot(), - storage.append_vec_id(), - )); + let output_path = staging_accounts_dir.join(crate::append_vec::AppendVec::file_name( + storage.slot(), + storage.append_vec_id(), + )); // `storage_path` - The file path where the AppendVec itself is located // `output_path` - The file path where the AppendVec will be placed in the staging directory.