Compute hash for both directory and store result in a vec
parent
583d7f1b9c
commit
f97430c21a
75
src/main.rs
75
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);
|
||||||
|
|
||||||
println!("Value for input: {}", args.input);
|
if args.vlevel >= 2 {
|
||||||
println!("Value for output: {}", args.output);
|
println!("Value for input: {}", args.input);
|
||||||
println!("Verbosity Level: {}", args.vlevel);
|
println!("Value for output: {}", args.output);
|
||||||
|
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,26 +200,29 @@ 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] {
|
||||||
.into_iter()
|
for entry in WalkDir::new(&s)
|
||||||
.filter_map(|e| e.ok())
|
.into_iter()
|
||||||
{
|
.filter_map(|e| e.ok())
|
||||||
// symlink_metadata does not follow symlink :-]
|
{
|
||||||
let metadata = fs::symlink_metadata(entry.path()).unwrap();
|
// symlink_metadata does not follow symlink :-]
|
||||||
let ft = metadata.file_type();
|
let metadata = fs::symlink_metadata(entry.path()).unwrap();
|
||||||
|
let ft = metadata.file_type();
|
||||||
|
|
||||||
if ft.is_file() {
|
if ft.is_file() {
|
||||||
if let Ok(mut file) = fs::File::open(&entry.path()) {
|
if let Ok(mut file) = fs::File::open(&entry.path()) {
|
||||||
let mut a = FileToProcess {
|
let mut a = FileToProcess {
|
||||||
name: format!("{}",
|
name: format!("{}",
|
||||||
entry.path().display()),
|
entry.path().display()),
|
||||||
hash: vec![],
|
hash: vec![],
|
||||||
realpath: String::from("TODO"),
|
realpath: String::from("TODO"),
|
||||||
};
|
};
|
||||||
a.hash::<Sha256, _>(&mut file);
|
|
||||||
println!("{}", a);
|
// compute file hash
|
||||||
files_candidate.push(a);
|
a.hash::<Sha256, _>(&mut file);
|
||||||
|
files_candidate.push(a);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -231,17 +231,6 @@ fn main() {
|
||||||
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