Use AsRef<Path>
instead of PathBuf
for parameters (#23560)
This commit is contained in:
@ -175,7 +175,7 @@ mod tests {
|
|||||||
|
|
||||||
let check_hash_calculation = false;
|
let check_hash_calculation = false;
|
||||||
let full_snapshot_archive_path = snapshot_utils::build_full_snapshot_archive_path(
|
let full_snapshot_archive_path = snapshot_utils::build_full_snapshot_archive_path(
|
||||||
snapshot_archives_dir.to_path_buf(),
|
snapshot_archives_dir,
|
||||||
old_last_bank.slot(),
|
old_last_bank.slot(),
|
||||||
&old_last_bank.get_accounts_hash(),
|
&old_last_bank.get_accounts_hash(),
|
||||||
ArchiveFormat::TarBzip2,
|
ArchiveFormat::TarBzip2,
|
||||||
@ -461,7 +461,7 @@ mod tests {
|
|||||||
fs_extra::dir::copy(&last_snapshot_path, &saved_snapshots_dir, &options).unwrap();
|
fs_extra::dir::copy(&last_snapshot_path, &saved_snapshots_dir, &options).unwrap();
|
||||||
|
|
||||||
saved_archive_path = Some(snapshot_utils::build_full_snapshot_archive_path(
|
saved_archive_path = Some(snapshot_utils::build_full_snapshot_archive_path(
|
||||||
snapshot_archives_dir.to_path_buf(),
|
snapshot_archives_dir,
|
||||||
slot,
|
slot,
|
||||||
&accounts_hash,
|
&accounts_hash,
|
||||||
ArchiveFormat::TarBzip2,
|
ArchiveFormat::TarBzip2,
|
||||||
|
@ -276,14 +276,14 @@ pub fn download_snapshot_archive<'a, 'b>(
|
|||||||
] {
|
] {
|
||||||
let destination_path = match snapshot_type {
|
let destination_path = match snapshot_type {
|
||||||
SnapshotType::FullSnapshot => snapshot_utils::build_full_snapshot_archive_path(
|
SnapshotType::FullSnapshot => snapshot_utils::build_full_snapshot_archive_path(
|
||||||
snapshot_archives_dir.to_path_buf(),
|
snapshot_archives_dir,
|
||||||
desired_snapshot_hash.0,
|
desired_snapshot_hash.0,
|
||||||
&desired_snapshot_hash.1,
|
&desired_snapshot_hash.1,
|
||||||
archive_format,
|
archive_format,
|
||||||
),
|
),
|
||||||
SnapshotType::IncrementalSnapshot(base_slot) => {
|
SnapshotType::IncrementalSnapshot(base_slot) => {
|
||||||
snapshot_utils::build_incremental_snapshot_archive_path(
|
snapshot_utils::build_incremental_snapshot_archive_path(
|
||||||
snapshot_archives_dir.to_path_buf(),
|
snapshot_archives_dir,
|
||||||
base_slot,
|
base_slot,
|
||||||
desired_snapshot_hash.0,
|
desired_snapshot_hash.0,
|
||||||
&desired_snapshot_hash.1,
|
&desired_snapshot_hash.1,
|
||||||
|
@ -1330,8 +1330,7 @@ fn test_snapshot_restart_tower() {
|
|||||||
let validator_archive_path = snapshot_utils::build_full_snapshot_archive_path(
|
let validator_archive_path = snapshot_utils::build_full_snapshot_archive_path(
|
||||||
validator_snapshot_test_config
|
validator_snapshot_test_config
|
||||||
.snapshot_archives_dir
|
.snapshot_archives_dir
|
||||||
.path()
|
.into_path(),
|
||||||
.to_path_buf(),
|
|
||||||
full_snapshot_archive_info.slot(),
|
full_snapshot_archive_info.slot(),
|
||||||
full_snapshot_archive_info.hash(),
|
full_snapshot_archive_info.hash(),
|
||||||
full_snapshot_archive_info.archive_format(),
|
full_snapshot_archive_info.archive_format(),
|
||||||
@ -1403,8 +1402,7 @@ fn test_snapshots_blockstore_floor() {
|
|||||||
let validator_archive_path = snapshot_utils::build_full_snapshot_archive_path(
|
let validator_archive_path = snapshot_utils::build_full_snapshot_archive_path(
|
||||||
validator_snapshot_test_config
|
validator_snapshot_test_config
|
||||||
.snapshot_archives_dir
|
.snapshot_archives_dir
|
||||||
.path()
|
.into_path(),
|
||||||
.to_path_buf(),
|
|
||||||
archive_info.slot(),
|
archive_info.slot(),
|
||||||
archive_info.hash(),
|
archive_info.hash(),
|
||||||
ArchiveFormat::TarBzip2,
|
ArchiveFormat::TarBzip2,
|
||||||
|
@ -1053,12 +1053,12 @@ pub fn path_to_file_name_str(path: &Path) -> Result<&str> {
|
|||||||
/// Build the full snapshot archive path from its components: the snapshot archives directory, the
|
/// Build the full snapshot archive path from its components: the snapshot archives directory, the
|
||||||
/// snapshot slot, the accounts hash, and the archive format.
|
/// snapshot slot, the accounts hash, and the archive format.
|
||||||
pub fn build_full_snapshot_archive_path(
|
pub fn build_full_snapshot_archive_path(
|
||||||
snapshot_archives_dir: PathBuf,
|
snapshot_archives_dir: impl AsRef<Path>,
|
||||||
slot: Slot,
|
slot: Slot,
|
||||||
hash: &Hash,
|
hash: &Hash,
|
||||||
archive_format: ArchiveFormat,
|
archive_format: ArchiveFormat,
|
||||||
) -> PathBuf {
|
) -> PathBuf {
|
||||||
snapshot_archives_dir.join(format!(
|
snapshot_archives_dir.as_ref().join(format!(
|
||||||
"snapshot-{}-{}.{}",
|
"snapshot-{}-{}.{}",
|
||||||
slot,
|
slot,
|
||||||
hash,
|
hash,
|
||||||
@ -1070,13 +1070,13 @@ pub fn build_full_snapshot_archive_path(
|
|||||||
/// directory, the snapshot base slot, the snapshot slot, the accounts hash, and the archive
|
/// directory, the snapshot base slot, the snapshot slot, the accounts hash, and the archive
|
||||||
/// format.
|
/// format.
|
||||||
pub fn build_incremental_snapshot_archive_path(
|
pub fn build_incremental_snapshot_archive_path(
|
||||||
snapshot_archives_dir: PathBuf,
|
snapshot_archives_dir: impl AsRef<Path>,
|
||||||
base_slot: Slot,
|
base_slot: Slot,
|
||||||
slot: Slot,
|
slot: Slot,
|
||||||
hash: &Hash,
|
hash: &Hash,
|
||||||
archive_format: ArchiveFormat,
|
archive_format: ArchiveFormat,
|
||||||
) -> PathBuf {
|
) -> PathBuf {
|
||||||
snapshot_archives_dir.join(format!(
|
snapshot_archives_dir.as_ref().join(format!(
|
||||||
"incremental-snapshot-{}-{}-{}.{}",
|
"incremental-snapshot-{}-{}-{}.{}",
|
||||||
base_slot,
|
base_slot,
|
||||||
slot,
|
slot,
|
||||||
|
Reference in New Issue
Block a user