diff --git a/src/commands/push/new.rs b/src/commands/push/new.rs index 9b949e4..c6eb863 100644 --- a/src/commands/push/new.rs +++ b/src/commands/push/new.rs @@ -68,7 +68,7 @@ impl PushChange for New { let lastmodified = prop.lastmodified.unwrap().timestamp_millis(); // update blob - blob::add(obj.path.clone(), &lastmodified.to_string())?; + blob::add(obj.path.clone(), &lastmodified.to_string(), true)?; // remove index index::rm_line(obj.path.to_str().unwrap())?; diff --git a/src/commands/push/new_dir.rs b/src/commands/push/new_dir.rs index a45d527..443f66b 100644 --- a/src/commands/push/new_dir.rs +++ b/src/commands/push/new_dir.rs @@ -74,7 +74,7 @@ impl PushChange for NewDir { let lastmodified = prop.lastmodified.unwrap().timestamp_millis(); // update tree - tree::add(obj.path.clone(), &lastmodified.to_string())?; + tree::add(obj.path.clone(), &lastmodified.to_string(), true)?; // remove index index::rm_line(obj.path.to_str().unwrap())?; diff --git a/src/store/object/blob.rs b/src/store/object/blob.rs index 4e3dee9..11009ab 100644 --- a/src/store/object/blob.rs +++ b/src/store/object/blob.rs @@ -5,7 +5,7 @@ use crate::utils::path; use crate::store::head; use crate::store::object::{update_dates, parse_path, add_node, create_obj, rm_node}; -pub fn add(path: PathBuf, date: &str) -> io::Result<()> { +pub fn add(path: PathBuf, date: &str, up_parent: bool) -> io::Result<()> { let (line, hash, name) = parse_path(path.clone(), true); // add blob reference to parent if path.iter().count() == 1 { @@ -22,7 +22,9 @@ pub fn add(path: PathBuf, date: &str) -> io::Result<()> { create_obj(hash, &content)?; // update date for all parent - update_dates(path, date)?; + if up_parent { + update_dates(path, date)?; + } Ok(()) } diff --git a/src/store/object/tree.rs b/src/store/object/tree.rs index 0d1903c..8ae05ec 100644 --- a/src/store/object/tree.rs +++ b/src/store/object/tree.rs @@ -5,7 +5,7 @@ use crate::utils::{read, path}; use crate::store::head; use crate::store::object::{self, update_dates, parse_path, hash_obj, add_node, create_obj}; -pub fn add(path: PathBuf, date: &str) -> io::Result<()> { +pub fn add(path: PathBuf, date: &str, up_parent: bool) -> io::Result<()> { let (line, hash, name) = parse_path(path.clone(), false); // add tree reference to parent @@ -22,7 +22,9 @@ pub fn add(path: PathBuf, date: &str) -> io::Result<()> { create_obj(hash, &content)?; // update date for all parent - update_dates(path, date)?; + if up_parent { + update_dates(path, date)?; + } Ok(()) }