diff --git a/src/pseudo_peer/cli.rs b/src/pseudo_peer/cli.rs index 7cdc922e1..7e90742c6 100644 --- a/src/pseudo_peer/cli.rs +++ b/src/pseudo_peer/cli.rs @@ -41,7 +41,7 @@ impl BlockSourceArgs { if let Some(bucket) = value.strip_prefix("s3://") { Ok(BlockSourceConfig::s3(bucket.to_string()).await) } else { - Ok(BlockSourceConfig::local(value.to_string())) + Ok(BlockSourceConfig::local(value.into())) } } diff --git a/src/pseudo_peer/config.rs b/src/pseudo_peer/config.rs index 11ed0d3de..5635020ab 100644 --- a/src/pseudo_peer/config.rs +++ b/src/pseudo_peer/config.rs @@ -1,12 +1,11 @@ -use aws_config::BehaviorVersion; - use super::{ consts::DEFAULT_S3_BUCKET, sources::{ BlockSourceBoxed, CachedBlockSource, HlNodeBlockSource, LocalBlockSource, S3BlockSource, }, }; -use std::{path::PathBuf, sync::Arc}; +use aws_config::BehaviorVersion; +use std::{env::home_dir, path::PathBuf, sync::Arc}; #[derive(Debug, Clone)] pub struct BlockSourceConfig { @@ -17,7 +16,7 @@ pub struct BlockSourceConfig { #[derive(Debug, Clone)] pub enum BlockSourceType { S3 { bucket: String }, - Local { path: String }, + Local { path: PathBuf }, } impl BlockSourceConfig { @@ -32,7 +31,7 @@ impl BlockSourceConfig { Self { source_type: BlockSourceType::S3 { bucket }, block_source_from_node: None } } - pub fn local(path: String) -> Self { + pub fn local(path: PathBuf) -> Self { Self { source_type: BlockSourceType::Local { path }, block_source_from_node: None } } diff --git a/src/pseudo_peer/tests.rs b/src/pseudo_peer/tests.rs index 8a0f625be..4c8b064bc 100644 --- a/src/pseudo_peer/tests.rs +++ b/src/pseudo_peer/tests.rs @@ -1,3 +1,5 @@ +use std::path::Path; + use crate::pseudo_peer::{prelude::*, BlockSourceType}; #[tokio::test] @@ -10,8 +12,10 @@ async fn test_block_source_config_s3() { #[tokio::test] async fn test_block_source_config_local() { - let config = BlockSourceConfig::local("/test/path".to_string()); - assert!(matches!(config.source_type, BlockSourceType::Local { path } if path == "/test/path")); + let config = BlockSourceConfig::local("/test/path".into()); + assert!( + matches!(config.source_type, BlockSourceType::Local { path } if path == Path::new("/test/path")) + ); } #[test]