rev
This commit is contained in:
parent
bbeafdad7e
commit
2cc43ffc23
@ -1,7 +1,7 @@
|
||||
[package]
|
||||
name = "sys-compare"
|
||||
description = "Track Filesystem Integrity via 'Snapshots' containing hash of all files within specified directories."
|
||||
version = "0.1.5"
|
||||
version = "0.1.6"
|
||||
edition = "2021"
|
||||
authors = ["james@koonts.net"]
|
||||
license = "MIT"
|
||||
@ -11,7 +11,7 @@ readme = "README.md"
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
filesystem-hashing = "0.2.4"
|
||||
filesystem-hashing = "0.2.6"
|
||||
clap = { version = "4.5.4", features = ["derive"] }
|
||||
whoami = "1.5.1"
|
||||
anyhow = "1.0.81"
|
||||
|
@ -1,22 +1,20 @@
|
||||
use crate::options::Arguments;
|
||||
use anyhow::Error;
|
||||
use filesystem_hashing::snapshot::{Snapshot, SnapshotChangeType, SnapshotCompareResult};
|
||||
use filesystem_hashing::{compare_snapshots, import_snapshot};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct CompareMode {
|
||||
left: Snapshot,
|
||||
right: Snapshot,
|
||||
selection: Option<String>,
|
||||
count_only: Option<bool>,
|
||||
#[allow(unused)]
|
||||
options: Arguments,
|
||||
result_type: SnapshotChangeType,
|
||||
results: SnapshotCompareResult,
|
||||
}
|
||||
|
||||
impl CompareMode {
|
||||
pub fn new(
|
||||
options: Arguments,
|
||||
left: String,
|
||||
right: String,
|
||||
selection: Option<String>,
|
||||
@ -30,7 +28,6 @@ impl CompareMode {
|
||||
right,
|
||||
selection,
|
||||
count_only,
|
||||
options,
|
||||
result_type: SnapshotChangeType::None,
|
||||
results: SnapshotCompareResult {
|
||||
created: vec![],
|
||||
@ -102,6 +99,7 @@ mod tests {
|
||||
use crate::createmode::CreateMode;
|
||||
use std::env;
|
||||
use std::fmt::format;
|
||||
use crate::options::{Arguments, Commands};
|
||||
|
||||
#[test]
|
||||
fn compare_mode() {
|
||||
@ -115,11 +113,17 @@ mod tests {
|
||||
let right_dir = format!("/home/{}/Documents/", user);
|
||||
println!("{right}");
|
||||
|
||||
let mut n1 = CreateMode::new(vec![], left.clone());
|
||||
n1.run();
|
||||
let mut n2 = CreateMode::new(vec![], right.clone());
|
||||
n2.run();
|
||||
let mut n1 = CreateMode::new(left.clone(), "/etc".to_string());
|
||||
let _ = n1.run();
|
||||
let mut n2 = CreateMode::new(right.clone(), "/etc".to_string());
|
||||
let _ = n2.run();
|
||||
|
||||
let cm = CompareMode::new(vec![], left.clone(), right.clone());
|
||||
let cm = CompareMode::new(left, right, None, None);
|
||||
|
||||
// println!("{:?}", cm);
|
||||
assert!(cm.left.file_hashes.lock().unwrap().len() > 0);
|
||||
assert!(cm.right.file_hashes.lock().unwrap().len() > 0);
|
||||
// assert!(cm.results. > 0);
|
||||
// todo()! finish writing tests
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ use clap::Parser;
|
||||
|
||||
fn main() {
|
||||
let options = Arguments::parse();
|
||||
let movable = options.clone();
|
||||
|
||||
let _app = match options.command {
|
||||
Commands::Create {
|
||||
@ -31,7 +30,7 @@ fn main() {
|
||||
println!("Running snapshot comparison..");
|
||||
}
|
||||
}
|
||||
let mut compare = CompareMode::new(movable.clone(), left, right, selection, count_only);
|
||||
let mut compare = CompareMode::new(left, right, selection, count_only);
|
||||
compare.run()
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user