diff --git a/crates/archivr-cli/src/main.rs b/crates/archivr-cli/src/main.rs index 482b298..d47c9c9 100644 --- a/crates/archivr-cli/src/main.rs +++ b/crates/archivr-cli/src/main.rs @@ -270,6 +270,9 @@ fn determine_source(path: &str) -> Source { return Source::Snapchat; } } + if Path::new(path).exists() { + return Source::Local; + } Source::Other } @@ -1196,6 +1199,16 @@ mod tests { } } + #[test] + fn test_existing_local_path_source() { + let path = env::current_dir().unwrap().join("Cargo.toml"); + assert_eq!( + determine_source(path.to_str().unwrap()), + Source::Local, + "existing filesystem paths should be archived as local files" + ); + } + #[test] fn test_initialize_store_directories() { let store_path = env::temp_dir().join(format!( diff --git a/crates/archivr-server/src/registry.rs b/crates/archivr-server/src/registry.rs index ca19456..c186d01 100644 --- a/crates/archivr-server/src/registry.rs +++ b/crates/archivr-server/src/registry.rs @@ -26,6 +26,7 @@ pub fn load_registry(path: &Path) -> Result { Ok(registry) } +#[cfg(test)] pub fn save_registry(path: &Path, registry: &ServerRegistry) -> Result<()> { validate_registry(registry)?; let contents = toml::to_string_pretty(registry)?;