diff --git a/src/push.rs b/src/push.rs index b8362b96c4149b58c165773807f3ec6b85d88523..47d49f5025bc6e2d0b1a457a877117aa2ef70640 100644 --- a/src/push.rs +++ b/src/push.rs @@ -451,13 +451,25 @@ pub(crate) fn split_path(url: &str) -> (String, PathBuf) { if res.len() == 1 { return ( String::from("file"), - PathBuf::from(url).canonicalize().unwrap(), + match PathBuf::from(url).canonicalize() { + Ok(path) => path, + Err(e) => { + eprintln!("{}: Problem with {}. {}", "error".red(), url, e); + exit(1); + } + }, ); } else if res.len() == 2 { if res[0].to_lowercase() == "file" { return ( String::from("file"), - PathBuf::from(res[1]).canonicalize().unwrap(), + match PathBuf::from(res[1]).canonicalize() { + Ok(path) => path, + Err(e) => { + eprintln!("{}: Problem with {}. {}", "error".red(), &res[1], e); + exit(1); + } + }, ); } return (res[0].to_owned(), PathBuf::from(res[1])); @@ -518,7 +530,7 @@ pub(crate) fn copy_file( remote_dir.to_str().unwrap().to_string() }; - let tmp = if cmd == "pull" { + let tmp = if cmd == "pull" || cmd == "clone" { format!("{}/", &remote_path) } else { format!("{}/", &borg_folder.display()) @@ -536,6 +548,17 @@ pub(crate) fn copy_file( &tmp, borg_folder.to_str().unwrap(), ] + } else if cmd == "clone" { + vec![ + "-a", + "--info=progress2", + "--human-readable", + "--exclude=.gblkconfig", + "--exclude=archive_list", + "--exclude=archive_list_remote", + &tmp, + borg_folder.to_str().unwrap(), + ] } else { vec![ "-a",