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
This commit is contained in:
Clement Tsang 2024-08-05 22:38:36 +00:00 committed by GitHub
parent d27790d6fa
commit 9f7e00497d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 16 additions and 2 deletions

View file

@ -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. - [#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 ## [0.10.1] - 2024-08-01
### Bug Fixes ### Bug Fixes

View file

@ -123,6 +123,7 @@ pub struct SysinfoSource {
impl Default for SysinfoSource { impl Default for SysinfoSource {
fn default() -> Self { fn default() -> Self {
use sysinfo::*; use sysinfo::*;
Self { Self {
system: System::new_with_specifics(RefreshKind::new()), system: System::new_with_specifics(RefreshKind::new()),
network: Networks::new(), network: Networks::new(),
@ -173,6 +174,10 @@ pub struct DataCollector {
impl DataCollector { impl DataCollector {
pub fn new(filters: DataFilters) -> Self { 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 { DataCollector {
data: Data::default(), data: Data::default(),
sys: SysinfoSource::default(), sys: SysinfoSource::default(),
@ -185,7 +190,7 @@ impl DataCollector {
temperature_type: TemperatureType::Celsius, temperature_type: TemperatureType::Celsius,
use_current_cpu_total: false, use_current_cpu_total: false,
unnormalized_cpu: 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_rx: 0,
total_tx: 0, total_tx: 0,
show_average_cpu: false, show_average_cpu: false,
@ -284,7 +289,12 @@ impl DataCollector {
#[cfg(not(target_os = "linux"))] #[cfg(not(target_os = "linux"))]
{ {
if self.widgets_to_harvest.use_proc { 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. // For Windows, sysinfo also handles the users list.
#[cfg(target_os = "windows")] #[cfg(target_os = "windows")]