Compute hash for both directory and store result in a vec
parent
583d7f1b9c
commit
f97430c21a
29
src/main.rs
29
src/main.rs
|
@ -65,9 +65,7 @@ impl Args {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_not_parent(&self) -> bool {
|
fn check_not_parent(&self) -> bool {
|
||||||
let vec = vec![&self.input, &self.output];
|
for (i, x) in vec![&self.input, &self.output].iter().enumerate() {
|
||||||
|
|
||||||
for (i, x) in vec.iter().enumerate() {
|
|
||||||
let mut a = Path::new(x);
|
let mut a = Path::new(x);
|
||||||
let tmp = match i {
|
let tmp = match i {
|
||||||
0 => &self.output,
|
0 => &self.output,
|
||||||
|
@ -172,16 +170,15 @@ fn main() {
|
||||||
t.fg(term::color::GREEN).unwrap();
|
t.fg(term::color::GREEN).unwrap();
|
||||||
let args = Args::new(&matches);
|
let args = Args::new(&matches);
|
||||||
|
|
||||||
|
if args.vlevel >= 2 {
|
||||||
println!("Value for input: {}", args.input);
|
println!("Value for input: {}", args.input);
|
||||||
println!("Value for output: {}", args.output);
|
println!("Value for output: {}", args.output);
|
||||||
println!("Verbosity Level: {}", args.vlevel);
|
println!("Verbosity Level: {}", args.vlevel);
|
||||||
|
|
||||||
if args.dryrun {
|
if args.dryrun {
|
||||||
println!("dry-run enabled");
|
println!("dry-run enabled");
|
||||||
} else if args.vlevel >= 2 {
|
} else if args.vlevel >= 2 {
|
||||||
t.fg(term::color::RED).unwrap();
|
|
||||||
println!("dry-run not enabled");
|
println!("dry-run not enabled");
|
||||||
t.reset().unwrap();
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check input & output
|
// Check input & output
|
||||||
|
@ -203,8 +200,9 @@ fn main() {
|
||||||
process::exit(1);
|
process::exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Output
|
// Walk through path 1 & 2 [Todo: threading]
|
||||||
for entry in WalkDir::new(&args.output)
|
for s in &[&args.input, &args.output] {
|
||||||
|
for entry in WalkDir::new(&s)
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter_map(|e| e.ok())
|
.filter_map(|e| e.ok())
|
||||||
{
|
{
|
||||||
|
@ -220,28 +218,19 @@ fn main() {
|
||||||
hash: vec![],
|
hash: vec![],
|
||||||
realpath: String::from("TODO"),
|
realpath: String::from("TODO"),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// compute file hash
|
||||||
a.hash::<Sha256, _>(&mut file);
|
a.hash::<Sha256, _>(&mut file);
|
||||||
println!("{}", a);
|
|
||||||
files_candidate.push(a);
|
files_candidate.push(a);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for i in files_candidate {
|
for i in files_candidate {
|
||||||
println!("{}", i);
|
println!("{}", i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// let inputs = fs::read_dir(&args.input).unwrap();
|
|
||||||
// for path in inputs {
|
|
||||||
// let path_str = path.unwrap().path().into_os_string().into_string().unwrap();
|
|
||||||
// println!("[I] Name: {}", path_str);
|
|
||||||
// if let Ok(mut file) = fs::File::open(&path_str) {
|
|
||||||
// process::<Sha256, _>(&mut file,
|
|
||||||
// &path_str);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
t.reset().unwrap();
|
t.reset().unwrap();
|
||||||
t.fg(term::color::CYAN).unwrap();
|
t.fg(term::color::CYAN).unwrap();
|
||||||
println!("Cheers !");
|
println!("Cheers !");
|
||||||
|
|
Loading…
Reference in New Issue