From 9f7e00497dc799c0bec369de0304b9ea9bc4cb38 Mon Sep 17 00:00:00 2001 From: Clement Tsang <34804052+ClementTsang@users.noreply.github.com> Date: Mon, 5 Aug 2024 22:38:36 +0000 Subject: [PATCH] bug: fix not updating sysinfo processes correctly (#1541) * bug: fix not updating sysinfo processes correctly * also fix a potential panic spot on slow computers * update changelog --- CHANGELOG.md | 4 ++++ src/data_collection.rs | 14 ++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index def83c74..2f48e74a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - [#1487](https://github.com/ClementTsang/bottom/pull/1487): Add option to move the AVG CPU bar to another row in basic mode. +### Bug Fixes + +- [#1541](https://github.com/ClementTsang/bottom/pull/1541): Fix some process details not updating for macOS and Windows. + ## [0.10.1] - 2024-08-01 ### Bug Fixes diff --git a/src/data_collection.rs b/src/data_collection.rs index d37931f9..a95b54ba 100644 --- a/src/data_collection.rs +++ b/src/data_collection.rs @@ -123,6 +123,7 @@ pub struct SysinfoSource { impl Default for SysinfoSource { fn default() -> Self { use sysinfo::*; + Self { system: System::new_with_specifics(RefreshKind::new()), network: Networks::new(), @@ -173,6 +174,10 @@ pub struct DataCollector { impl DataCollector { pub fn new(filters: DataFilters) -> Self { + // Initialize it to the past to force it to load on initialization. + let now = Instant::now(); + let last_collection_time = now.checked_sub(Duration::from_secs(600)).unwrap_or(now); + DataCollector { data: Data::default(), sys: SysinfoSource::default(), @@ -185,7 +190,7 @@ impl DataCollector { temperature_type: TemperatureType::Celsius, use_current_cpu_total: false, unnormalized_cpu: false, - last_collection_time: Instant::now() - Duration::from_secs(600), /* Initialize it to the past to force it to load on initialization. */ + last_collection_time, total_rx: 0, total_tx: 0, show_average_cpu: false, @@ -284,7 +289,12 @@ impl DataCollector { #[cfg(not(target_os = "linux"))] { if self.widgets_to_harvest.use_proc { - self.sys.system.refresh_processes(); + self.sys.system.refresh_processes_specifics( + sysinfo::ProcessRefreshKind::everything() + .without_environ() + .without_cwd() + .without_root(), + ); // For Windows, sysinfo also handles the users list. #[cfg(target_os = "windows")]