diff options
author | ClementTsang <cjhtsang@uwaterloo.ca> | 2020-09-03 03:18:18 -0400 |
---|---|---|
committer | ClementTsang <cjhtsang@uwaterloo.ca> | 2020-09-03 03:18:18 -0400 |
commit | 3843d63dbbd0953b9edfcf802c977c0b35211987 (patch) | |
tree | f12d80412b16cc0978bc2e98cbc5276c6d3e5e96 | |
parent | 105e9d27bb699256d2676baa2fcf9c1049da773a (diff) |
bug: change heim io fn to not bail on any error
-rw-r--r-- | src/app/data_harvester/disks.rs | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/src/app/data_harvester/disks.rs b/src/app/data_harvester/disks.rs index 788f05ce..a9599bad 100644 --- a/src/app/data_harvester/disks.rs +++ b/src/app/data_harvester/disks.rs @@ -72,28 +72,30 @@ pub async fn get_heim_io_usage_list( if get_physical { let mut physical_counter_stream = heim::disk::io_counters_physical(); while let Some(io) = physical_counter_stream.next().await { - let io = io?; - let mount_point = io.device_name().to_str().unwrap_or("Name Unavailable"); - io_hash.insert( - mount_point.to_string(), - Some(IOData { - read_bytes: io.read_bytes().get::<heim::units::information::megabyte>(), - write_bytes: io.write_bytes().get::<heim::units::information::megabyte>(), - }), - ); + if let Ok(io) = io { + let mount_point = io.device_name().to_str().unwrap_or("Name Unavailable"); + io_hash.insert( + mount_point.to_string(), + Some(IOData { + read_bytes: io.read_bytes().get::<heim::units::information::megabyte>(), + write_bytes: io.write_bytes().get::<heim::units::information::megabyte>(), + }), + ); + } } } else { let mut counter_stream = heim::disk::io_counters(); while let Some(io) = counter_stream.next().await { - let io = io?; - let mount_point = io.device_name().to_str().unwrap_or("Name Unavailable"); - io_hash.insert( - mount_point.to_string(), - Some(IOData { - read_bytes: io.read_bytes().get::<heim::units::information::byte>(), - write_bytes: io.write_bytes().get::<heim::units::information::byte>(), - }), - ); + if let Ok(io) = io { + let mount_point = io.device_name().to_str().unwrap_or("Name Unavailable"); + io_hash.insert( + mount_point.to_string(), + Some(IOData { + read_bytes: io.read_bytes().get::<heim::units::information::byte>(), + write_bytes: io.write_bytes().get::<heim::units::information::byte>(), + }), + ); + } } } |