diff --git a/src/commands/add.rs b/src/commands/add.rs index ea690f8..bae3a4c 100644 --- a/src/commands/add.rs +++ b/src/commands/add.rs @@ -47,10 +47,10 @@ pub fn add(args: AddArgs) { let path = repo_root().join(Path::new(&f)); match path.exists() { true => { + added_files.push(f); if path.is_dir() { add_folder_content(path.to_path_buf(), &mut added_files); } - added_files.push(f); }, false => { if Object::new(path.to_str().unwrap()).exists() { @@ -64,10 +64,10 @@ pub fn add(args: AddArgs) { if !args.force && ignore_file(&path_buf_to_string(entry.clone()), rules.clone(), &mut ignored_f) { continue; } + added_files.push(path_buf_to_string(entry.strip_prefix(repo_root()).unwrap().to_path_buf())); if entry.is_dir() { add_folder_content(entry.to_path_buf(), &mut added_files); } - added_files.push(path_buf_to_string(entry.strip_prefix(repo_root()).unwrap().to_path_buf())); } } } diff --git a/src/commands/push/new.rs b/src/commands/push/new.rs index 10066cc..e6da312 100644 --- a/src/commands/push/new.rs +++ b/src/commands/push/new.rs @@ -32,6 +32,7 @@ impl PushChange for New { match res { Err(ApiError::IncorrectRequest(err)) => { + dbg!(&err); eprintln!("fatal: error pushing file '{}': {}", obj.name, err.status()); std::process::exit(1); }, diff --git a/src/commands/push/new_dir.rs b/src/commands/push/new_dir.rs index 39d156b..16cf637 100644 --- a/src/commands/push/new_dir.rs +++ b/src/commands/push/new_dir.rs @@ -31,6 +31,7 @@ impl PushChange for NewDir { } fn push(&self) -> io::Result<()> { + dbg!("pushing new dir"); let obj = &self.obj; let res = CreateFolder::new() .set_url(obj.path.to_str().unwrap()) diff --git a/src/store/object.rs b/src/store/object.rs index 0a98261..6d481e4 100644 --- a/src/store/object.rs +++ b/src/store/object.rs @@ -148,7 +148,7 @@ fn add_node(path: &Path, node: &str) -> io::Result<()> { root.push(dir); if !root.exists() { - todo!(); + //todo!(); } root.push(rest); diff --git a/src/store/object/object.rs b/src/store/object/object.rs index c6e5391..315d2db 100644 --- a/src/store/object/object.rs +++ b/src/store/object/object.rs @@ -22,6 +22,7 @@ pub trait ObjMethods { fn get_obj_path(&self) -> PathBuf; fn get_file_path(&self) -> PathBuf; fn get_relative_file_path(&self) -> PathBuf; + fn get_repo_file_path(&self) -> PathBuf; fn get_name(&self) -> String; fn get_hash_path(&self) -> String; fn get_local_obj(&self) -> LocalObj; @@ -38,6 +39,7 @@ pub struct Obj { obj_type: ObjType, file_path: PathBuf, // file here is used as both file and directory relative_file_path: PathBuf, + repo_file_path: PathBuf, hash_path: String, // hash of the relative path of the file } @@ -59,6 +61,10 @@ impl ObjMethods for Obj { self.relative_file_path.clone() } + fn get_repo_file_path(&self) -> PathBuf { + self.repo_file_path.clone() + } + fn get_local_obj(&self) -> LocalObj { LocalObj { otype: match self.obj_type { @@ -67,7 +73,7 @@ impl ObjMethods for Obj { ObjType::DEFAULT => String::from("default"), }, name: self.get_name(), - path: self.get_file_path(), + path: self.get_repo_file_path(), path_from: None, state: State::New } @@ -139,6 +145,10 @@ impl ObjMethods for Blob { self.obj.get_relative_file_path() } + fn get_repo_file_path(&self) -> PathBuf { + self.obj.get_repo_file_path() + } + fn get_local_obj(&self) -> LocalObj { self.obj.get_local_obj() } @@ -196,6 +206,10 @@ impl ObjMethods for Tree { self.obj.get_relative_file_path() } + fn get_repo_file_path(&self) -> PathBuf { + self.obj.get_repo_file_path() + } + fn get_local_obj(&self) -> LocalObj { self.obj.get_local_obj() } @@ -254,7 +268,8 @@ impl Obj { file_path: PathBuf::new(), obj_type: ObjType::DEFAULT, hash_path: String::new(), - relative_file_path: PathBuf::new() + relative_file_path: PathBuf::new(), + repo_file_path: PathBuf::new() } } @@ -285,7 +300,8 @@ impl Obj { false => ObjType::DEFAULT }, file_path: abs_path, - relative_file_path: path, + relative_file_path: path.clone(), + repo_file_path: path, hash_path: hash, } } @@ -324,7 +340,8 @@ impl Obj { _ => ObjType::DEFAULT }, file_path: abs_path, - relative_file_path: path, + relative_file_path: path.clone(), + repo_file_path: path, hash_path: String::from(hash_path), }; @@ -342,6 +359,7 @@ impl Obj { obj_type: ObjType::TREE, file_path: PathBuf::new(), relative_file_path: PathBuf::new(), + repo_file_path: PathBuf::new(), hash_path: String::new(), } } diff --git a/src/store/object/tree.rs b/src/store/object/tree.rs index ba3076f..5cb5782 100644 --- a/src/store/object/tree.rs +++ b/src/store/object/tree.rs @@ -85,10 +85,10 @@ impl Tree { // create tree object let mut content = format!("{} {}", self.get_name(), date); //create_obj(self.get_hash_path(), &content)?; - todo!(); + // todo!(); // update date for all parent - todo!(); + //todo!(); //if up_parent { // update_dates(path, date)?; //}