.
This commit is contained in:
parent
01a38428f0
commit
bc7689b538
@ -91,13 +91,15 @@ mod tests {
|
|||||||
println!("{user}");
|
println!("{user}");
|
||||||
|
|
||||||
let left = format!("/home/{}/test1", user);
|
let left = format!("/home/{}/test1", user);
|
||||||
|
let left_dir = format!("/home/{}/Downloads/", user);
|
||||||
println!("{left}");
|
println!("{left}");
|
||||||
let right = format!("/home/{}/test2", user);
|
let right = format!("/home/{}/test2", user);
|
||||||
|
let right_dir = format!("/home/{}/Downloads/", user);
|
||||||
println!("{right}");
|
println!("{right}");
|
||||||
|
|
||||||
let mut n1 = CreateMode::new(vec![], left.clone());
|
let mut n1 = CreateMode::new(vec![], left.clone(), left_dir);
|
||||||
n1.run();
|
n1.run();
|
||||||
let mut n2 = CreateMode::new(vec![], right.clone());
|
let mut n2 = CreateMode::new(vec![], right.clone(), right_dir);
|
||||||
n2.run();
|
n2.run();
|
||||||
|
|
||||||
let cm = CompareMode::new(vec![], left.clone(), right.clone());
|
let cm = CompareMode::new(vec![], left.clone(), right.clone());
|
||||||
|
@ -4,26 +4,27 @@ use Fasching::snapshot::Snapshot;
|
|||||||
use crate::syscompare::Comparer;
|
use crate::syscompare::Comparer;
|
||||||
|
|
||||||
pub struct CreateMode {
|
pub struct CreateMode {
|
||||||
path: String,
|
snapshot_path: String,
|
||||||
|
root_path: String,
|
||||||
args: Vec<String>,
|
args: Vec<String>,
|
||||||
snapshot: Snapshot
|
snapshot: Snapshot
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CreateMode {
|
impl CreateMode {
|
||||||
pub fn new(args: Vec<String>, path: String) -> CreateMode {
|
pub fn new(args: Vec<String>, snapshot_path: String, root_path: String) -> CreateMode {
|
||||||
if path.replace("./", "").is_empty() {
|
if snapshot_path.replace("./", "").is_empty() {
|
||||||
panic!("Specify output file name")
|
panic!("Specify output file name")
|
||||||
}
|
}
|
||||||
|
|
||||||
CreateMode { args, path, snapshot: Default::default() }
|
CreateMode { args, snapshot_path, root_path, snapshot: Default::default() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Comparer for CreateMode {
|
impl Comparer for CreateMode {
|
||||||
fn run(&mut self) {
|
fn run(&mut self) {
|
||||||
let snapshot = create_snapshot(self.path.as_str(), BLAKE3, vec![]);
|
let snapshot = create_snapshot(self.root_path.as_str(), BLAKE3, vec![]);
|
||||||
self.snapshot = snapshot.clone();
|
self.snapshot = snapshot.clone();
|
||||||
println!("Total FileHash Entries {}", snapshot.file_hashes.lock().unwrap().len());
|
println!("Total FileHash Entries {}", snapshot.file_hashes.lock().unwrap().len());
|
||||||
let _ = export_snapshot(self.snapshot.clone(), self.path.clone());
|
let _ = export_snapshot(self.snapshot.clone(), self.snapshot_path.clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,11 +25,15 @@ impl SysCompareApp {
|
|||||||
println!("running");
|
println!("running");
|
||||||
match self.mode {
|
match self.mode {
|
||||||
SysCompareMode::Create => {
|
SysCompareMode::Create => {
|
||||||
let path = match self.args.get(2) {
|
let snapshot_path = match self.args.get(2) {
|
||||||
None => {panic!("Missing hash dir path as second argument")}
|
None => {panic!("Missing hash dir path as second argument")}
|
||||||
Some(r) => {not_empty(r)}
|
Some(r) => {not_empty(r)}
|
||||||
};
|
};
|
||||||
let mut create = CreateMode::new(self.args.clone(), path.clone());
|
let root_dir = match self.args.get(2) {
|
||||||
|
None => {panic!("Missing hash dir path as second argument")}
|
||||||
|
Some(r) => {not_empty(r)}
|
||||||
|
};
|
||||||
|
let mut create = CreateMode::new(self.args.clone(), snapshot_path.clone(), root_dir.clone());
|
||||||
create.run()
|
create.run()
|
||||||
}
|
}
|
||||||
SysCompareMode::Compare => {
|
SysCompareMode::Compare => {
|
||||||
|
Loading…
Reference in New Issue
Block a user