use PathBuf in obj instead of &Path and get lastmodified when pushing changes

This commit is contained in:
grimhilt
2023-07-02 18:50:33 +02:00
parent 5ccce48381
commit ddf2169950
8 changed files with 71 additions and 13 deletions

View File

@@ -1,5 +1,6 @@
use std::path::PathBuf;
use crate::services::api::ApiError;
use crate::services::req_props::{ReqProps, ObjProps};
use crate::services::upload_file::UploadFile;
use crate::store::index;
use crate::store::object::blob;
@@ -40,8 +41,33 @@ impl PushChange for New {
_ => (),
}
// update tree
blob::add(&obj.path.clone(), "todo_date");
// get lastmodified props to update it
let props = ReqProps::new()
.set_url(obj.path.to_str().unwrap())
.getlastmodified()
.send_req_single();
let prop = match props {
Ok(o) => o,
Err(ApiError::IncorrectRequest(err)) => {
eprintln!("fatal: {}", err.status());
std::process::exit(1);
},
Err(ApiError::EmptyError(_)) => {
eprintln!("Failed to get body");
std::process::exit(1);
}
Err(ApiError::RequestError(err)) => {
eprintln!("fatal: {}", err);
std::process::exit(1);
},
Err(ApiError::Unexpected(_)) => todo!()
};
let lastmodified = prop.lastmodified.unwrap().timestamp_millis();
// update blob
blob::add(obj.path.clone(), &lastmodified.to_string());
// remove index
index::rm_line(obj.path.to_str().unwrap());