fix bug where a failed stat would cause the consumer thread to hang

This commit is contained in:
bp 2015-03-03 22:41:30 -05:00
parent 53a723b4ba
commit d9a0458a39

View File

@ -69,7 +69,8 @@ impl<'a> Exa<'a> {
// Communication between consumer thread and producer threads
enum StatResult<'a> {
File(File<'a>),
Path(Path)
Path(Path),
Error
}
let (results_tx, results_rx) = channel();
@ -84,7 +85,8 @@ impl<'a> Exa<'a> {
match results_rx.recv() {
Ok(result) => match result {
StatResult::File(file) => self.files.push(file),
StatResult::Path(path) => self.dirs.push(path)
StatResult::Path(path) => self.dirs.push(path),
StatResult::Error => ()
},
Err(_) => unreachable!()
}
@ -116,7 +118,10 @@ impl<'a> Exa<'a> {
let _ = results_tx.send(StatResult::File(File::with_stat(stat, &path, None, false)));
}
}
Err(e) => println!("{}: {}", file, e),
Err(e) => {
println!("{}: {}", file, e);
let _ = results_tx.send(StatResult::Error);
}
}
});
}