This commit is contained in:
grimhilt
2023-06-06 19:47:15 +02:00
parent 762ab25619
commit c5abc57e9a
5 changed files with 7 additions and 17 deletions

View File

@@ -1,10 +1,8 @@
use std::env;
use std::fs::OpenOptions;
use std::fs::DirBuilder;
use std::io::prelude::*;
use std::io::Cursor;
use std::path::{Path, PathBuf};
use std::ffi::OsStr;
use clap::Values;
use regex::Regex;
use xml::reader::{EventReader, XmlEvent};
@@ -39,7 +37,6 @@ pub fn clone(remote: Values<'_>) {
lp
},
};
dbg!((local_path.clone()));
let mut folders = vec![String::from(dist_path_str)];
let mut url_request;
@@ -70,12 +67,11 @@ pub fn clone(remote: Values<'_>) {
// destination path 'path' already exists and is not an empty directory.
//std::process::exit(1);
} else {
dbg!(local_path.to_str());
commands::init::init(Some(local_path.to_str().unwrap()));
commands::init::init();
}
} else {
// create folder
let mut local_folder = get_local_path(folder, local_path.clone(), username, dist_path_str);
let local_folder = get_local_path(folder, local_path.clone(), username, dist_path_str);
dbg!(DirBuilder::new().recursive(true).create(local_folder.clone()));
// add tree
@@ -104,7 +100,7 @@ fn get_local_path(p: String, local_p: PathBuf, username: &str, dist_p: &str) ->
let mut final_p = Path::new(p.as_str());
final_p = final_p.strip_prefix("/remote.php/dav/files/").unwrap();
final_p = final_p.strip_prefix(username.clone()).unwrap();
let mut dist_p = Path::new(dist_p).strip_prefix("/");
let dist_p = Path::new(dist_p).strip_prefix("/");
final_p = final_p.strip_prefix(dist_p.unwrap()).unwrap();
local_p.clone().join(final_p.clone())
}

View File

@@ -3,9 +3,9 @@ use std::path::PathBuf;
use std::env;
use crate::global::global::DIR_PATH;
pub fn init(directory: Option<&str>) {
pub fn init() {
let d = DIR_PATH.lock().unwrap();
dbg!(d.clone());
let mut path = match d.clone() {
Some(dir) => PathBuf::from(dir),
None => env::current_dir().unwrap(),