From 55a93355383bc8c31c0b42c0ec3f162aa548de46 Mon Sep 17 00:00:00 2001 From: Fontrodona Nicolas <nicolas.fontrodona@ens-lyon.fr> Date: Wed, 1 Feb 2023 18:21:05 +0100 Subject: [PATCH] copy_file: add new command in copy_file function --- src/push.rs | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/src/push.rs b/src/push.rs index b8362b9..47d49f5 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", -- GitLab