mirror of
https://github.com/amtoaer/bili-sync.git
synced 2026-09-06 16:07:26 +08:00
fix: 修改过滤逻辑,避免某些存储空间由于磁盘类型探测失败而被错误过滤的情况 (#568)
This commit is contained in:
@@ -16,8 +16,8 @@ pub use log_helper::{LogHelper, MAX_HISTORY_LOGS};
|
|||||||
use parking_lot::RwLock;
|
use parking_lot::RwLock;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use sysinfo::{
|
use sysinfo::{
|
||||||
CpuRefreshKind, DiskKind, DiskRefreshKind, Disks, MemoryRefreshKind, Pid, ProcessRefreshKind, ProcessesToUpdate,
|
CpuRefreshKind, DiskRefreshKind, Disks, MemoryRefreshKind, Pid, ProcessRefreshKind, ProcessesToUpdate, System,
|
||||||
System, get_current_pid,
|
get_current_pid,
|
||||||
};
|
};
|
||||||
use tokio::sync::mpsc;
|
use tokio::sync::mpsc;
|
||||||
use tokio::{pin, select};
|
use tokio::{pin, select};
|
||||||
@@ -248,7 +248,13 @@ impl WebSocketHandler {
|
|||||||
};
|
};
|
||||||
let (available, total) = disks
|
let (available, total) = disks
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|d| !matches!(d.kind(), DiskKind::Unknown(_)))
|
.filter(|d| {
|
||||||
|
d.available_space() > 0
|
||||||
|
&& d.total_space() > 0
|
||||||
|
// 简单过滤一些虚拟文件系统
|
||||||
|
&& !["overlay", "tmpfs", "sysfs", "proc"]
|
||||||
|
.contains(&d.file_system().to_string_lossy().as_ref())
|
||||||
|
})
|
||||||
.unique_by(|d| d.name())
|
.unique_by(|d| d.name())
|
||||||
.fold((0, 0), |(mut available, mut total), d| {
|
.fold((0, 0), |(mut available, mut total), d| {
|
||||||
available += d.available_space();
|
available += d.available_space();
|
||||||
@@ -326,6 +332,6 @@ impl SysInfoExt for System {
|
|||||||
|
|
||||||
impl SysInfoExt for Disks {
|
impl SysInfoExt for Disks {
|
||||||
fn refresh_needed(&mut self, _self_pid: Pid) {
|
fn refresh_needed(&mut self, _self_pid: Pid) {
|
||||||
self.refresh_specifics(true, DiskRefreshKind::nothing().with_storage().with_kind());
|
self.refresh_specifics(true, DiskRefreshKind::nothing().with_storage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user