Fix device detection, tree indentation, and hide Single storage type
- Replace findmnt with lsblk for efficient device name detection - Fix tree indentation to align consistently with status icon text - Hide '(Single)' label for single disk storage pools - Device detection returns actual names (nvme0n1, sda) not UUID paths
This commit is contained in:
parent
9f34c67bfa
commit
ad298ac70c
@ -262,10 +262,10 @@ impl DiskCollector {
|
||||
}
|
||||
}
|
||||
|
||||
/// Detect device backing a mount point using findmnt (static version for startup)
|
||||
/// Detect device backing a mount point using lsblk (static version for startup)
|
||||
fn detect_device_for_mount_point_static(mount_point: &str) -> Result<Vec<String>> {
|
||||
let output = Command::new("findmnt")
|
||||
.args(&["-n", "-o", "SOURCE", mount_point])
|
||||
let output = Command::new("lsblk")
|
||||
.args(&["-n", "-o", "NAME,MOUNTPOINT"])
|
||||
.output()?;
|
||||
|
||||
if !output.status.success() {
|
||||
@ -273,16 +273,18 @@ impl DiskCollector {
|
||||
}
|
||||
|
||||
let output_str = String::from_utf8_lossy(&output.stdout);
|
||||
let device_path = output_str.trim();
|
||||
|
||||
// Extract device name from path (e.g., /dev/nvme0n1 -> nvme0n1)
|
||||
if let Some(device_name) = device_path.strip_prefix("/dev/") {
|
||||
Ok(vec![device_name.to_string()])
|
||||
} else {
|
||||
Ok(Vec::new())
|
||||
for line in output_str.lines() {
|
||||
let parts: Vec<&str> = line.split_whitespace().collect();
|
||||
if parts.len() >= 2 && parts[1] == mount_point {
|
||||
let device_name = parts[0].trim();
|
||||
return Ok(vec![device_name.to_string()]);
|
||||
}
|
||||
}
|
||||
|
||||
Ok(Vec::new())
|
||||
}
|
||||
|
||||
/// Get directory size using du command (efficient for single directory)
|
||||
fn get_directory_size(&self, path: &str) -> Result<u64> {
|
||||
let output = Command::new("du")
|
||||
|
||||
@ -254,9 +254,14 @@ impl SystemWidget {
|
||||
_ => "—% —GB/—GB".to_string(),
|
||||
};
|
||||
|
||||
let pool_label = if pool.pool_type.to_lowercase() == "single" {
|
||||
format!("{}:", pool.mount_point)
|
||||
} else {
|
||||
format!("{} ({}):", pool.mount_point, pool.pool_type)
|
||||
};
|
||||
let pool_spans = StatusIcons::create_status_spans(
|
||||
pool.status.clone(),
|
||||
&format!("{} ({}):", pool.mount_point, pool.pool_type)
|
||||
&pool_label
|
||||
);
|
||||
lines.push(Line::from(pool_spans));
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user