mirror of
https://github.com/posborne/rust-pstree.git
synced 2025-03-03 22:24:40 +01:00
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:
parent
60a15fe7b1
commit
f6a26552ef
1 changed files with 4 additions and 2 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue