.
This commit is contained in:
parent
811f1fa30d
commit
4d244af93f
@ -83,13 +83,22 @@ mod tests {
|
|||||||
use std::fmt::format;
|
use std::fmt::format;
|
||||||
use crate::comparemode::CompareMode;
|
use crate::comparemode::CompareMode;
|
||||||
use crate::createmode::CreateMode;
|
use crate::createmode::CreateMode;
|
||||||
|
use crate::syscompare::Comparer;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn compare_mode() {
|
fn compare_mode() {
|
||||||
let user = whoami::username();
|
let user = whoami::username();
|
||||||
|
println!("{user}");
|
||||||
|
|
||||||
let left = format!("/home/{}/test1", user);
|
let left = format!("/home/{}/test1", user);
|
||||||
|
println!("{left}");
|
||||||
let right = format!("/home/{}/test2", user);
|
let right = format!("/home/{}/test2", user);
|
||||||
let n1 = CreateMode::new(vec![], left.clone(), right.clone());
|
println!("{right}");
|
||||||
|
|
||||||
|
let mut n1 = CreateMode::new(vec![], left.clone());
|
||||||
|
n1.run();
|
||||||
|
let mut n2 = CreateMode::new(vec![], right.clone());
|
||||||
|
n2.run();
|
||||||
|
|
||||||
let cm = CompareMode::new(vec![], left.clone(), right.clone());
|
let cm = CompareMode::new(vec![], left.clone(), right.clone());
|
||||||
}
|
}
|
||||||
|
@ -4,26 +4,26 @@ use Fasching::snapshot::Snapshot;
|
|||||||
use crate::syscompare::Comparer;
|
use crate::syscompare::Comparer;
|
||||||
|
|
||||||
pub struct CreateMode {
|
pub struct CreateMode {
|
||||||
in_path: String,
|
path: String,
|
||||||
out_path: String,
|
|
||||||
args: Vec<String>,
|
args: Vec<String>,
|
||||||
snapshot: Snapshot
|
snapshot: Snapshot
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CreateMode {
|
impl CreateMode {
|
||||||
pub fn new(args: Vec<String>, in_path: String, out_path: String) -> CreateMode {
|
pub fn new(args: Vec<String>, path: String) -> CreateMode {
|
||||||
if out_path.replace("./", "").is_empty() {
|
if path.replace("./", "").is_empty() {
|
||||||
panic!("Specify output file name")
|
panic!("Specify output file name")
|
||||||
}
|
}
|
||||||
|
|
||||||
CreateMode { in_path, out_path, args, snapshot: Default::default() }
|
CreateMode { args, 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.in_path.as_str(), BLAKE3);
|
let snapshot = create_snapshot(self.path.as_str(), BLAKE3);
|
||||||
|
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(snapshot, self.out_path.clone());
|
let _ = export_snapshot(self.snapshot.clone(), self.path.clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,15 +25,11 @@ impl SysCompareApp {
|
|||||||
println!("running");
|
println!("running");
|
||||||
match self.mode {
|
match self.mode {
|
||||||
SysCompareMode::Create => {
|
SysCompareMode::Create => {
|
||||||
let in_path = match self.args.get(2) {
|
let 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 out_path = match self.args.get(3) {
|
let mut create = CreateMode::new(self.args.clone(), path.clone());
|
||||||
None => {panic!("Missing output path as third argument")}
|
|
||||||
Some(r) => {not_empty(r)}
|
|
||||||
};
|
|
||||||
let mut create = CreateMode::new(self.args.clone(), in_path.clone(), out_path.clone());
|
|
||||||
create.run()
|
create.run()
|
||||||
}
|
}
|
||||||
SysCompareMode::Compare => {
|
SysCompareMode::Compare => {
|
||||||
|
Loading…
Reference in New Issue
Block a user