Skip to content

Commit

Permalink
bug: fix not updating sysinfo processes correctly (#1541)
Browse files Browse the repository at this point in the history
* bug: fix not updating sysinfo processes correctly

* also fix a potential panic spot on slow computers

* update changelog
  • Loading branch information
ClementTsang authored Aug 5, 2024
1 parent d27790d commit 9f7e004
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 12 additions & 2 deletions src/data_collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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(),
Expand All @@ -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,
Expand Down Expand Up @@ -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")]
Expand Down

0 comments on commit 9f7e004

Please sign in to comment.