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