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-25 16:36:46 +00:00
|
|
|
path: String,
|
2024-03-18 22:04:24 +00:00
|
|
|
args: Vec<String>,
|
2024-03-18 21:47:21 +00:00
|
|
|
snapshot: Snapshot
|
|
|
|
}
|
|
|
|
|
|
|
|
impl CreateMode {
|
2024-03-25 16:36:46 +00:00
|
|
|
pub fn new(args: Vec<String>, path: String) -> CreateMode {
|
|
|
|
if path.replace("./", "").is_empty() {
|
2024-03-18 22:14:05 +00:00
|
|
|
panic!("Specify output file name")
|
|
|
|
}
|
|
|
|
|
2024-03-25 16:36:46 +00:00
|
|
|
CreateMode { args, path, snapshot: Default::default() }
|
2024-03-18 21:47:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Comparer for CreateMode {
|
2024-03-18 22:37:17 +00:00
|
|
|
fn run(&mut self) {
|
2024-03-25 16:42:29 +00:00
|
|
|
let snapshot = create_snapshot(self.path.as_str(), BLAKE3, vec![]);
|
2024-03-25 16:36:46 +00:00
|
|
|
self.snapshot = snapshot.clone();
|
2024-03-18 22:14:05 +00:00
|
|
|
println!("Total FileHash Entries {}", snapshot.file_hashes.lock().unwrap().len());
|
2024-03-25 16:36:46 +00:00
|
|
|
let _ = export_snapshot(self.snapshot.clone(), self.path.clone());
|
2024-03-18 21:47:21 +00:00
|
|
|
}
|
|
|
|
}
|