Skip to content

Commit

Permalink
fix mistmach return types
Browse files Browse the repository at this point in the history
  • Loading branch information
Abdenasser committed Nov 9, 2024
1 parent 82eb442 commit 250eb37
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use sysinfo::{
ProcessExt,
PidExt,
};
use std::slice::Iter;
use tauri::State;
use std::sync::Mutex;
use std::collections::HashMap;
Expand Down Expand Up @@ -79,16 +78,17 @@ pub struct SystemStats {

// Assume MacOS or Linux
#[cfg(not(target_os = "windows"))]
fn filter_disks(disks: &[Disk]) -> Iter<Disk> {
fn filter_disks(disks: &[Disk]) -> Vec<&sysinfo::Disk> {
disks.iter().filter(|disk| {
// Filter for physical disks - typically those mounted at "/"
disk.mount_point() == std::path::Path::new("/")
})
.collect()
}

#[cfg(target_os = "windows")]
fn filter_disks(disks: &[Disk]) -> Iter<Disk> {
disks.iter()
fn filter_disks(disks: &[Disk]) -> Vec<&sysinfo::Disk> {
disks.iter().collect()
}

#[tauri::command]
Expand Down Expand Up @@ -138,7 +138,8 @@ async fn get_processes(state: State<'_, AppState>) -> Result<(Vec<ProcessInfo>,
*last_update = (current_time, current_rx, current_tx);

// Calculate total disk usage
let disk_stats = filter_disks(& sys.disks())
let disk_stats = filter_disks(&sys.disks())
.iter()
.fold((0, 0, 0), |acc, disk| {
(
acc.0 + disk.total_space(),
Expand Down

0 comments on commit 250eb37

Please sign in to comment.