bug: change heim io fn to not bail on any error

This commit is contained in:
ClementTsang 2020-09-03 03:18:18 -04:00
parent 105e9d27bb
commit 3843d63dbb
1 changed files with 20 additions and 18 deletions

View File

@ -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>(),
}),
);
}
}
}