mirror of
https://github.com/ClementTsang/bottom
synced 2024-11-22 12:13:06 +00:00
Added 'used' field in disks polling, as it is more accurate
This commit is contained in:
parent
ef2dc7e1b5
commit
826bc701c1
2 changed files with 6 additions and 7 deletions
|
@ -1,7 +1,3 @@
|
|||
use futures::{
|
||||
future::{err, join_all, ok},
|
||||
prelude::*,
|
||||
};
|
||||
use sysinfo::{System, SystemExt};
|
||||
|
||||
mod widgets;
|
||||
|
@ -37,6 +33,7 @@ async fn main() {
|
|||
sys.refresh_network();
|
||||
|
||||
// What we want to do: For timed data, if there is an error, just do not add. For other data, just don't update!
|
||||
// TODO: Joining all would be better...
|
||||
list_of_timed_network.push(network::get_network_data(&sys));
|
||||
|
||||
if let Ok(process_vec) = processes::get_sorted_processes_list(processes::ProcessSorting::CPU, true).await {
|
||||
|
@ -66,7 +63,7 @@ async fn main() {
|
|||
);
|
||||
}
|
||||
for disk in &list_of_disks {
|
||||
println!("{} is mounted on {}: {}/{} free.", disk.name, disk.mount_point, disk.avail_space as f64, disk.total_space as f64);
|
||||
println!("{} is mounted on {}: {} used.", disk.name, disk.mount_point, disk.used_space as f64 / disk.total_space as f64);
|
||||
// TODO: Check if this is valid
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,8 @@ use heim_common::prelude::StreamExt;
|
|||
pub struct DiskInfo {
|
||||
pub name : Box<str>,
|
||||
pub mount_point : Box<str>,
|
||||
pub avail_space : u64,
|
||||
pub free_space : u64,
|
||||
pub used_space : u64,
|
||||
pub total_space : u64,
|
||||
}
|
||||
|
||||
|
@ -59,7 +60,8 @@ pub async fn get_disk_usage_list() -> Result<Vec<DiskInfo>, heim::Error> {
|
|||
let usage = heim::disk::usage(partition.mount_point().to_path_buf()).await?;
|
||||
|
||||
vec_disks.push(DiskInfo {
|
||||
avail_space : usage.free().get::<heim_common::units::information::megabyte>(),
|
||||
free_space : usage.free().get::<heim_common::units::information::megabyte>(),
|
||||
used_space : usage.used().get::<heim_common::units::information::megabyte>(),
|
||||
total_space : usage.total().get::<heim_common::units::information::megabyte>(),
|
||||
mount_point : Box::from(partition.mount_point().to_str().unwrap_or("Name Unavailable")),
|
||||
name : Box::from(partition.device().unwrap_or_else(|| std::ffi::OsStr::new("Name Unavailable")).to_str().unwrap_or("Name Unavailable")),
|
||||
|
|
Loading…
Reference in a new issue