cleaning all warnings
This commit is contained in:
@@ -9,7 +9,8 @@ pub mod rm_dir;
|
||||
pub mod deleted;
|
||||
|
||||
pub fn push() {
|
||||
let remote = match config::get("remote") {
|
||||
// todo
|
||||
let _remote = match config::get("remote") {
|
||||
Some(r) => r,
|
||||
None => {
|
||||
eprintln!("fatal: no remote set in configuration");
|
||||
@@ -27,11 +28,17 @@ pub fn push() {
|
||||
|
||||
for obj in staged_objs {
|
||||
if obj.otype == String::from("tree") {
|
||||
dbg!(("folder", obj.clone()));
|
||||
let push_factory = PushFactory.new_dir(obj.clone());
|
||||
let res = push_factory.can_push(&mut whitelist);
|
||||
match res {
|
||||
PushState::Valid => push_factory.push(),
|
||||
PushState::Valid => {
|
||||
match push_factory.push() {
|
||||
Ok(()) => (),
|
||||
Err(err) => {
|
||||
eprintln!("err: pushing {}: {}", obj.name, err);
|
||||
}
|
||||
}
|
||||
},
|
||||
PushState::Done => (),
|
||||
PushState::Conflict => {
|
||||
println!("CONFLICT: {}", obj.clone().name);
|
||||
@@ -40,10 +47,16 @@ pub fn push() {
|
||||
};
|
||||
|
||||
} else {
|
||||
dbg!(("file", obj.clone()));
|
||||
let push_factory = PushFactory.new(obj.clone());
|
||||
match push_factory.can_push(&mut whitelist) {
|
||||
PushState::Valid => push_factory.push(),
|
||||
PushState::Valid => {
|
||||
match push_factory.push() {
|
||||
Ok(()) => (),
|
||||
Err(err) => {
|
||||
eprintln!("err: pushing {}: {}", obj.name, err);
|
||||
}
|
||||
}
|
||||
},
|
||||
PushState::Done => (),
|
||||
PushState::Conflict => {
|
||||
// download file
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use std::path::PathBuf;
|
||||
use std::io;
|
||||
use crate::services::api::ApiError;
|
||||
use crate::services::req_props::ReqProps;
|
||||
use crate::services::delete_path::DeletePath;
|
||||
use crate::store::index;
|
||||
use crate::store::object::blob;
|
||||
@@ -22,7 +22,7 @@ impl PushChange for Deleted {
|
||||
}
|
||||
}
|
||||
|
||||
fn push(&self) {
|
||||
fn push(&self) -> io::Result<()> {
|
||||
let obj = &self.obj;
|
||||
let res = DeletePath::new()
|
||||
.set_url(obj.path.to_str().unwrap())
|
||||
@@ -41,9 +41,13 @@ impl PushChange for Deleted {
|
||||
}
|
||||
|
||||
// update tree
|
||||
blob::rm(obj.path.clone());
|
||||
// todo date
|
||||
blob::rm(obj.path.clone())?;
|
||||
|
||||
// remove index
|
||||
index::rm_line(obj.path.to_str().unwrap());
|
||||
index::rm_line(obj.path.to_str().unwrap())?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn conflict(&self) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
use std::path::PathBuf;
|
||||
use std::io;
|
||||
use crate::services::api::ApiError;
|
||||
use crate::services::req_props::{ReqProps, ObjProps};
|
||||
use crate::services::req_props::ReqProps;
|
||||
use crate::services::upload_file::UploadFile;
|
||||
use crate::store::index;
|
||||
use crate::store::object::blob;
|
||||
@@ -22,7 +23,7 @@ impl PushChange for New {
|
||||
}
|
||||
}
|
||||
|
||||
fn push(&self) {
|
||||
fn push(&self) -> io::Result<()> {
|
||||
let obj = &self.obj;
|
||||
let res = UploadFile::new()
|
||||
.set_url(obj.path.to_str().unwrap())
|
||||
@@ -67,10 +68,12 @@ 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())?;
|
||||
|
||||
// remove index
|
||||
index::rm_line(obj.path.to_str().unwrap());
|
||||
index::rm_line(obj.path.to_str().unwrap())?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// download file with .distant at the end
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
use std::path::PathBuf;
|
||||
use std::io;
|
||||
use crate::services::api::ApiError;
|
||||
use crate::services::req_props::{ReqProps, ObjProps};
|
||||
use crate::services::req_props::ReqProps;
|
||||
use crate::services::create_folder::CreateFolder;
|
||||
use crate::store::index;
|
||||
use crate::store::object::tree;
|
||||
@@ -28,7 +29,7 @@ impl PushChange for NewDir {
|
||||
}
|
||||
}
|
||||
|
||||
fn push(&self) {
|
||||
fn push(&self) -> io::Result<()> {
|
||||
let obj = &self.obj;
|
||||
let res = CreateFolder::new()
|
||||
.set_url(obj.path.to_str().unwrap())
|
||||
@@ -71,13 +72,14 @@ impl PushChange for NewDir {
|
||||
};
|
||||
|
||||
let lastmodified = prop.lastmodified.unwrap().timestamp_millis();
|
||||
dbg!(lastmodified);
|
||||
|
||||
// update tree
|
||||
tree::add(obj.path.clone(), &lastmodified.to_string());
|
||||
tree::add(obj.path.clone(), &lastmodified.to_string())?;
|
||||
|
||||
// remove index
|
||||
index::rm_line(obj.path.to_str().unwrap());
|
||||
index::rm_line(obj.path.to_str().unwrap())?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn conflict(&self) {}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
use std::path::PathBuf;
|
||||
use std::io;
|
||||
use crate::commands::status::{State, LocalObj};
|
||||
use crate::services::api::ApiError;
|
||||
use crate::store::object;
|
||||
use crate::services::req_props::{ObjProps, ReqProps};
|
||||
use crate::services::req_props::ReqProps;
|
||||
use crate::commands::push::new::New;
|
||||
use crate::commands::push::new_dir::NewDir;
|
||||
use crate::commands::push::rm_dir::RmDir;
|
||||
@@ -26,18 +27,9 @@ pub enum PushFlowState {
|
||||
|
||||
pub trait PushChange {
|
||||
fn can_push(&self, whitelist: &mut Option<PathBuf>) -> PushState;
|
||||
fn push(&self);
|
||||
fn push(&self) -> io::Result<()>;
|
||||
fn conflict(&self);
|
||||
|
||||
fn try_push(&self, whitelist: &mut Option<PathBuf>) {
|
||||
match self.can_push(whitelist) {
|
||||
PushState::Valid => self.push(),
|
||||
PushState::Conflict => self.conflict(),
|
||||
PushState::Done => (),
|
||||
PushState::Error => (),
|
||||
}
|
||||
}
|
||||
|
||||
fn is_whitelisted(&self, obj: &LocalObj, path: Option<PathBuf>) -> bool {
|
||||
match path {
|
||||
Some(p) => obj.path.starts_with(p),
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use std::path::PathBuf;
|
||||
use std::io;
|
||||
use crate::services::api::ApiError;
|
||||
use crate::services::delete_path::DeletePath;
|
||||
use crate::store::index;
|
||||
@@ -27,7 +28,7 @@ impl PushChange for RmDir {
|
||||
}
|
||||
}
|
||||
|
||||
fn push(&self) {
|
||||
fn push(&self) -> io::Result<()> {
|
||||
let obj = &self.obj;
|
||||
let res = DeletePath::new()
|
||||
.set_url(obj.path.to_str().unwrap())
|
||||
@@ -47,9 +48,12 @@ impl PushChange for RmDir {
|
||||
|
||||
// update tree
|
||||
// todo update date
|
||||
tree::rm(obj.path.clone());
|
||||
tree::rm(obj.path.clone())?;
|
||||
|
||||
// remove index
|
||||
index::rm_line(obj.path.to_str().unwrap());
|
||||
index::rm_line(obj.path.to_str().unwrap())?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn conflict(&self) {}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use std::fs::File;
|
||||
use std::path::PathBuf;
|
||||
use std::io::{self, Lines, BufReader};
|
||||
use std::collections::{HashSet, HashMap};
|
||||
use std::collections::HashMap;
|
||||
use crypto::digest::Digest;
|
||||
use crypto::sha1::Sha1;
|
||||
use colored::Colorize;
|
||||
@@ -31,7 +31,7 @@ pub enum State {
|
||||
pub fn status() {
|
||||
let (mut new_objs_hashes, mut del_objs_hashes) = get_diff();
|
||||
// get copy, modified
|
||||
let mut staged_objs = get_staged(&mut new_objs_hashes, &mut del_objs_hashes);
|
||||
let staged_objs = get_staged(&mut new_objs_hashes, &mut del_objs_hashes);
|
||||
|
||||
let mut objs: Vec<LocalObj> = del_objs_hashes.iter().map(|x| {
|
||||
x.1.clone()
|
||||
@@ -41,8 +41,6 @@ pub fn status() {
|
||||
objs.push(elt.clone());
|
||||
}
|
||||
|
||||
dbg!(objs.clone());
|
||||
dbg!(staged_objs.clone());
|
||||
print_status(staged_objs, objs);
|
||||
}
|
||||
|
||||
@@ -57,7 +55,7 @@ pub struct LocalObj {
|
||||
pub fn get_all_staged() -> Vec<LocalObj> {
|
||||
let (mut new_objs_hashes, mut del_objs_hashes) = get_diff();
|
||||
// get copy, modified
|
||||
let mut staged_objs = get_staged(&mut new_objs_hashes, &mut del_objs_hashes);
|
||||
let staged_objs = get_staged(&mut new_objs_hashes, &mut del_objs_hashes);
|
||||
|
||||
staged_objs.clone()
|
||||
// todo opti getting staged and then finding differences ?
|
||||
|
||||
Reference in New Issue
Block a user