.
This commit is contained in:
parent
01a38428f0
commit
bc7689b538
@ -91,13 +91,15 @@ mod tests {
|
||||
println!("{user}");
|
||||
|
||||
let left = format!("/home/{}/test1", user);
|
||||
let left_dir = format!("/home/{}/Downloads/", user);
|
||||
println!("{left}");
|
||||
let right = format!("/home/{}/test2", user);
|
||||
let right_dir = format!("/home/{}/Downloads/", user);
|
||||
println!("{right}");
|
||||
|
||||
let mut n1 = CreateMode::new(vec![], left.clone());
|
||||
let mut n1 = CreateMode::new(vec![], left.clone(), left_dir);
|
||||
n1.run();
|
||||
let mut n2 = CreateMode::new(vec![], right.clone());
|
||||
let mut n2 = CreateMode::new(vec![], right.clone(), right_dir);
|
||||
n2.run();
|
||||
|
||||
let cm = CompareMode::new(vec![], left.clone(), right.clone());
|
||||
|
@ -4,26 +4,27 @@ use Fasching::snapshot::Snapshot;
|
||||
use crate::syscompare::Comparer;
|
||||
|
||||
pub struct CreateMode {
|
||||
path: String,
|
||||
snapshot_path: String,
|
||||
root_path: String,
|
||||
args: Vec<String>,
|
||||
snapshot: Snapshot
|
||||
}
|
||||
|
||||
impl CreateMode {
|
||||
pub fn new(args: Vec<String>, path: String) -> CreateMode {
|
||||
if path.replace("./", "").is_empty() {
|
||||
pub fn new(args: Vec<String>, snapshot_path: String, root_path: String) -> CreateMode {
|
||||
if snapshot_path.replace("./", "").is_empty() {
|
||||
panic!("Specify output file name")
|
||||
}
|
||||
|
||||
CreateMode { args, path, snapshot: Default::default() }
|
||||
CreateMode { args, snapshot_path, root_path, snapshot: Default::default() }
|
||||
}
|
||||
}
|
||||
|
||||
impl Comparer for CreateMode {
|
||||
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();
|
||||
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");
|
||||
match self.mode {
|
||||
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")}
|
||||
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()
|
||||
}
|
||||
SysCompareMode::Compare => {
|
||||
|
Loading…
Reference in New Issue
Block a user