Skip to content

Commit

Permalink
Update sysinfo requirement from 0.29.10 to 0.30.0
Browse files Browse the repository at this point in the history
Updates the requirements on [sysinfo](https://github.com/GuillaumeGomez/sysinfo) to permit the latest version.
- [Changelog](https://github.com/GuillaumeGomez/sysinfo/blob/master/CHANGELOG.md)
- [Commits](https://github.com/GuillaumeGomez/sysinfo/commits)

---
updated-dependencies:
- dependency-name: sysinfo
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
  • Loading branch information
dependabot[bot] authored and CryZe committed Dec 21, 2023
1 parent 23e31b3 commit c24d1a1
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ libc = { version = "0.2.101", optional = true }
seahash = "4.1.0"

[target.'cfg(windows)'.dev-dependencies]
sysinfo = { version = "0.29.10", default-features = false }
sysinfo = { version = "0.30.0", default-features = false }

[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
criterion = "0.5.0"
Expand Down
2 changes: 1 addition & 1 deletion crates/livesplit-auto-splitting/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ proc-maps = { version = "0.3.0", default-features = false }
read-process-memory = { version = "0.1.4", default-features = false }
slotmap = { version = "1.0.2", default-features = false }
snafu = "0.7.0"
sysinfo = { version = "0.29.0", default-features = false, features = [
sysinfo = { version = "0.30.0", default-features = false, features = [
"multithread",
] }
time = { version = "0.3.3", default-features = false }
Expand Down
5 changes: 2 additions & 3 deletions crates/livesplit-auto-splitting/src/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use std::{
use proc_maps::{MapRange, Pid};
use read_process_memory::{CopyAddress, ProcessHandle};
use snafu::{OptionExt, ResultExt, Snafu};
use sysinfo::{self, PidExt, ProcessExt};

use crate::{runtime::ProcessList, wasi_path};

Expand Down Expand Up @@ -69,7 +68,7 @@ impl Process {
.max_by_key(|p| (p.start_time(), p.pid().as_u32()))
.context(ProcessDoesntExist)?;

let path = wasi_path::from_native(process.exe());
let path = process.exe().and_then(wasi_path::from_native);

let pid = process.pid().as_u32() as Pid;

Expand All @@ -92,7 +91,7 @@ impl Process {
.get(sysinfo::Pid::from_u32(pid))
.context(ProcessDoesntExist)?;

let path = wasi_path::from_native(process.exe());
let path = process.exe().and_then(wasi_path::from_native);

let pid_out = pid as Pid;

Expand Down
23 changes: 15 additions & 8 deletions crates/livesplit-auto-splitting/src/runtime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use std::{
},
time::{Duration, Instant},
};
use sysinfo::{ProcessExt, ProcessRefreshKind, RefreshKind, System, SystemExt};
use sysinfo::{ProcessRefreshKind, RefreshKind, System, UpdateKind};
use wasmtime::{
Engine, Extern, Linker, Memory, Module, OptLevel, Store, TypedFunc, WasmBacktraceDetails,
};
Expand Down Expand Up @@ -111,7 +111,7 @@ impl ProcessList {
fn new() -> Self {
Self {
system: System::new_with_specifics(
RefreshKind::new().with_processes(ProcessRefreshKind::new()),
RefreshKind::new().with_processes(multiple_processes()),
),
next_check: Instant::now() + Duration::from_secs(1),
}
Expand All @@ -121,22 +121,19 @@ impl ProcessList {
let now = Instant::now();
if now >= self.next_check {
self.system
.refresh_processes_specifics(ProcessRefreshKind::new());
.refresh_processes_specifics(multiple_processes());
self.next_check = now + Duration::from_secs(1);
}
}

pub fn refresh_single_process(&mut self, pid: sysinfo::Pid) {
if !self
.system
.refresh_process_specifics(pid, ProcessRefreshKind::new())
{
if !self.system.refresh_process_specifics(pid, single_process()) {
// FIXME: Unfortunately `refresh_process_specifics` doesn't remove
// the process if it doesn't exist anymore. There also doesn't seem
// to be a way to manually remove it. So we have to do a full
// refresh of all processes.
self.system
.refresh_processes_specifics(ProcessRefreshKind::new());
.refresh_processes_specifics(multiple_processes());
self.next_check = Instant::now() + Duration::from_secs(1);
}
}
Expand All @@ -160,6 +157,16 @@ impl ProcessList {
}
}

#[inline]
fn multiple_processes() -> ProcessRefreshKind {
ProcessRefreshKind::new().with_exe(UpdateKind::OnlyIfNotSet)
}

#[inline]
fn single_process() -> ProcessRefreshKind {
ProcessRefreshKind::new()
}

/// The configuration to use when creating a new [`Runtime`].
#[non_exhaustive]
pub struct Config {
Expand Down
5 changes: 1 addition & 4 deletions tests/rendering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ fn font_fallback() {
// world:
// https://en.wikipedia.org/wiki/List_of_writing_systems#List_of_writing_systems_by_adoption

use sysinfo::SystemExt;

let mut run = tests_helper::create_run(&[
// Emoji
"❤✔👌🤔😂😁🎉💀🤣",
Expand Down Expand Up @@ -102,8 +100,7 @@ fn font_fallback() {

let _state = layout.state(&timer.snapshot());

let system = sysinfo::System::new();
let build_number: u64 = system.kernel_version().unwrap().parse().unwrap();
let build_number: u64 = sysinfo::System::kernel_version().unwrap().parse().unwrap();
let expected_hash = if build_number >= 22000 {
// Windows 11
"04fd5c64e5ca85f5"
Expand Down

0 comments on commit c24d1a1

Please sign in to comment.