improve status and minor fixes
This commit is contained in:
parent
4e20ec94f9
commit
2775c77c55
@ -9,6 +9,7 @@ pub mod rm_dir;
|
||||
pub mod deleted;
|
||||
|
||||
pub fn push() {
|
||||
// todo err when pushing new folder
|
||||
// todo
|
||||
let _remote = match config::get("remote") {
|
||||
Some(r) => r,
|
||||
|
@ -6,6 +6,7 @@ use crypto::digest::Digest;
|
||||
use crypto::sha1::Sha1;
|
||||
use colored::Colorize;
|
||||
use crate::utils::path;
|
||||
use crate::store::head;
|
||||
use crate::utils::read::{read_folder, read_lines};
|
||||
use crate::store::object::tree;
|
||||
use crate::store::index;
|
||||
@ -116,11 +117,11 @@ fn get_diff() -> (HashMap<String, LocalObj>, HashMap<String, LocalObj>) {
|
||||
|
||||
let root = path::repo_root();
|
||||
|
||||
let nextsync_path = path::nextsync();
|
||||
let current_p = path::current().unwrap();
|
||||
// todo use repo_root instead of current
|
||||
let dist_path = current_p.strip_prefix(root.clone()).unwrap().to_path_buf();
|
||||
|
||||
if let Ok(lines) = read_head(nextsync_path.clone()) {
|
||||
if let Ok(lines) = read_lines(head::path()) {
|
||||
add_to_hashmap(lines, &mut hashes, dist_path.clone());
|
||||
}
|
||||
|
||||
@ -164,10 +165,12 @@ fn get_diff() -> (HashMap<String, LocalObj>, HashMap<String, LocalObj>) {
|
||||
hasher.input_str(&obj);
|
||||
let hash = hasher.result_str();
|
||||
hasher.reset();
|
||||
|
||||
let p = PathBuf::from(obj.to_string());
|
||||
let abs_p = path::repo_root().join(p.clone());
|
||||
// todo name
|
||||
new_objs_hashes.insert(String::from(hash), LocalObj {
|
||||
otype: get_otype(p.clone()),
|
||||
otype: get_otype(abs_p),
|
||||
name: obj.to_string(),
|
||||
path: p,
|
||||
state: State::New
|
||||
|
@ -4,7 +4,6 @@ use std::fs::{self, OpenOptions};
|
||||
use crypto::sha1::Sha1;
|
||||
use crypto::digest::Digest;
|
||||
use std::io::{Seek, SeekFrom, Read};
|
||||
use crate::utils::time::parse_timestamp;
|
||||
use crate::store::head;
|
||||
use crate::utils::{read, path};
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
use crate::commands::{clone::get_url_props, config};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct ApiProps {
|
||||
pub host: String, // nextcloud.example.com
|
||||
@ -15,6 +17,23 @@ impl Clone for ApiProps {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_api_props() -> ApiProps {
|
||||
let remote = match config::get("remote") {
|
||||
Some(r) => r,
|
||||
None => {
|
||||
eprintln!("fatal: unable to find a remote");
|
||||
std::process::exit(1);
|
||||
}
|
||||
};
|
||||
|
||||
let (host, username, root) = get_url_props(&remote);
|
||||
ApiProps {
|
||||
host,
|
||||
username: username.unwrap().to_owned(),
|
||||
root: root.to_owned(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_relative_s(p: String, api_props: &ApiProps) -> String {
|
||||
let mut final_p = p.clone();
|
||||
final_p = final_p.strip_prefix("/remote.php/dav/files/").unwrap().to_string();
|
||||
|
Loading…
Reference in New Issue
Block a user