Skip to content

Commit

Permalink
Merge pull request #28 from raytung/fix/proper-error-propagation-for-…
Browse files Browse the repository at this point in the history
…broken-pipes

fix: Properly handling broken pipe errors instead of panic-ing
  • Loading branch information
raytung authored Jan 15, 2022
2 parents b1e1c93 + 37fbb84 commit 27438e0
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::fs::read;
use std::io::{stdout, Write};

use clap::Parser;
use ignore::WalkBuilder;
Expand Down Expand Up @@ -45,11 +46,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let hash_str = to_hex(hash.as_slice());

if opt.verbose {
println!(
"{} {}",
hash_str,
dir_entry.path().to_str().unwrap_or(""),
);
writeln!(stdout(), "{} {}", hash_str, dir_entry.path().to_str().unwrap_or(""))?;
}

hashes.push(hash_str);
Expand All @@ -68,7 +65,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let final_hash = Sha256::digest(concatenated_hashes.as_bytes());
let final_hash_str = to_hex(final_hash.as_slice());

println!("{}", final_hash_str);
writeln!(stdout(), "{}", final_hash_str)?;

Ok(())
}

0 comments on commit 27438e0

Please sign in to comment.