Upgraded sysinfo to v0.40.4

This commit is contained in:
Thorsten Sommer committed 2026-11-26 12:27:10 +01:00
1 parent 69ae920c90
commit cdeb2379e0
4 files changed
+54 -18

No files matched your search

+16 -14
View File
@@ -4374,7 +4374,7 @@ dependencies = [
"subtle",
"symphonia",
"sys-locale",
"sysinfo",
"sysinfo 0.40.4",
"tauri",
"tauri-build",
"tauri-plugin-dialog",
@@ -4952,17 +4952,6 @@ dependencies = [
"objc2-core-foundation",
]
[[package]]
name = "objc2-open-directory"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bb82bed227edf5201dfedf072bba4015a33d3d4a98519837295a90f0a23f676d"
dependencies = [
"objc2",
"objc2-core-foundation",
"objc2-foundation",
]
[[package]]
name = "objc2-osa-kit"
version = "0.3.2"
@@ -5820,7 +5809,7 @@ dependencies = [
"smallvec",
"strum",
"stumpalo",
"sysinfo",
"sysinfo 0.39.6",
"tap",
"tar",
"tempfile",
@@ -7488,7 +7477,20 @@ dependencies = [
"ntapi",
"objc2-core-foundation",
"objc2-io-kit",
"objc2-open-directory",
"windows",
]
[[package]]
name = "sysinfo"
version = "0.40.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3e80749408e2d8bec0ffa303012cf4e1b3b355f4a09087b4fdf7473680f6a2de"
dependencies = [
"libc",
"memchr",
"ntapi",
"objc2-core-foundation",
"objc2-io-kit",
"windows",
]
+1 -1
View File
@@ -88,7 +88,7 @@ onenote_parser = "2.1.0"
typed-path = "0.12.4"
tempfile = "3.27.0"
strum_macros = "0.28.0"
sysinfo = "0.39.6"
sysinfo = { version = "0.40.4", default-features = false, features = ["system", "disk"] }
bytes = "1.12.2"
qdrant-edge = "0.9.0"
+1 -1
View File
@@ -805,7 +805,7 @@ fn ensure_enough_space(required_bytes: u64, available_bytes: Option<u64>) -> Qdr
/// path as it is serves as the fallback.
fn available_space(path: &Path) -> Option<u64> {
let disks = sysinfo::Disks::new_with_refreshed_list()
.list()
.ok()?
.iter()
.map(|disk| DiskSpace {
mount_point: disk.mount_point().to_path_buf(),
+36 -2
View File
@@ -32,7 +32,8 @@ pub fn kill_stale_process(pid_file_path: PathBuf, sidecar_type: SidecarType) ->
let pid_file_content = fs::read_to_string(&pid_file_path)?;
let (pid, expected_name) = parse_pid_file(&pid_file_content)?;
let mut system = System::new_all();
// Refreshing the one process adds it, so the system needs to load nothing else:
let mut system = System::new().map_err(Error::other)?;
let pid = Pid::from_u32(pid);
system.refresh_processes(ProcessesToUpdate::Some(&[pid]), true);
@@ -63,7 +64,17 @@ pub fn kill_stale_process(pid_file_path: PathBuf, sidecar_type: SidecarType) ->
}
pub fn log_potential_stale_process(pid_file_path: PathBuf, pid: u32, sidecar_type: SidecarType) {
let mut system = System::new_all();
let mut system = match System::new() {
Ok(system) => system,
Err(e) => {
warn!(Source="Stale Process Cleanup";
"{}: Pid file with process number '{}' was not created because the processes could not be read: {}",
sidecar_type, pid, e
);
return;
}
};
let pid = Pid::from_u32(pid);
system.refresh_processes(ProcessesToUpdate::Some(&[pid]), true);
let Some(process) = system.process(pid) else {
@@ -87,3 +98,26 @@ pub fn log_potential_stale_process(pid_file_path: PathBuf, pid: u32, sidecar_typ
}
}
}
#[cfg(test)]
mod tests {
use super::*;
/// Verifies that a process found by its number alone gets a PID file and is killed later on.
#[cfg(unix)]
#[test]
fn stale_process_is_recorded_and_killed() {
use std::os::unix::process::ExitStatusExt;
let mut child = std::process::Command::new("sleep").arg("30").spawn().unwrap();
let pid_file_path = std::env::temp_dir().join(format!("ai-studio-stale-process-{}.pid", rand::random::<u64>()));
log_potential_stale_process(pid_file_path.clone(), child.id(), SidecarType::Dotnet);
let content = fs::read_to_string(&pid_file_path).unwrap();
assert_eq!(content, format!("{}\nsleep\n", child.id()));
kill_stale_process(pid_file_path.clone(), SidecarType::Dotnet).unwrap();
assert!(!pid_file_path.exists());
assert_eq!(child.wait().unwrap().signal(), Some(9));
}
}