sys-compare/src/createmode.rs

30 lines
859 B
Rust
Raw Normal View History

2024-03-18 22:14:05 +00:00
use Fasching::{create_snapshot, export_snapshot};
2024-03-18 22:04:24 +00:00
use Fasching::hasher::HashType::BLAKE3;
2024-03-18 21:47:21 +00:00
use Fasching::snapshot::Snapshot;
use crate::syscompare::Comparer;
2024-03-18 21:51:52 +00:00
pub struct CreateMode {
2024-03-18 22:04:24 +00:00
in_path: String,
out_path: String,
args: Vec<String>,
2024-03-18 21:47:21 +00:00
snapshot: Snapshot
}
impl CreateMode {
2024-03-18 22:04:24 +00:00
pub fn new(args: Vec<String>, in_path: String, out_path: String) -> CreateMode {
2024-03-18 22:14:05 +00:00
if out_path.replace("./", "").is_empty() {
panic!("Specify output file name")
}
2024-03-18 22:04:24 +00:00
CreateMode { in_path, out_path, args, snapshot: Default::default() }
2024-03-18 21:47:21 +00:00
}
}
impl Comparer for CreateMode {
fn run(&self) {
2024-03-18 22:04:24 +00:00
let snapshot = create_snapshot(self.in_path.as_str(), BLAKE3);
2024-03-18 22:14:05 +00:00
println!("Total FileHash Entries {}", snapshot.file_hashes.lock().unwrap().len());
let _ = export_snapshot(snapshot, self.out_path.clone());
2024-03-18 21:47:21 +00:00
}
}