allow not updating parent's date when cloning

This commit is contained in:
grimhilt 2023-07-13 00:21:37 +02:00
parent 5bc9ef0035
commit 2d4905f506
4 changed files with 10 additions and 6 deletions

View File

@ -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())?;

View File

@ -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())?;

View File

@ -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(())
}

View File

@ -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(())
}