fix: don't panic! if potential status path doesn't exist

The error handling was wrong previously.  If the path didn't exist (at
all) then fs::metadata() returned an error that we subsequently
unwrapped.  I didn't see this until I tested on F23.

Signed-off-by: Paul Osborne <osbpau@gmail.com>
This commit is contained in:
Paul Osborne 2015-12-06 10:49:07 -06:00
parent 60a15fe7b1
commit f6a26552ef

View file

@ -108,8 +108,10 @@ fn get_process_records() -> Vec<ProcessRecord> {
let entry_path = entry.unwrap().path();
if fs::metadata(entry_path.as_path()).unwrap().is_dir() {
let status_path = entry_path.join("status");
if fs::metadata(status_path.as_path()).unwrap().is_file() {
return get_process_record(status_path.as_path())
if let Ok(metadata) = fs::metadata(status_path.as_path()) {
if metadata.is_file() {
return get_process_record(status_path.as_path());
}
}
}
None