Filter out unusable drives

This commit is contained in:
Jeremy Soller
2023-01-11 21:06:13 -07:00
parent fce55b54db
commit 28e3544f4a
+18 -5
View File
@@ -30,6 +30,11 @@ fn disk_paths() -> Result<Vec<(String, u64)>, String> {
if let Ok(path_str) = path.into_os_string().into_string() {
let scheme = path_str.trim_start_matches(':').trim_matches('/');
if scheme.starts_with("disk") {
if scheme == "disk/live" {
// Skip live disks
continue;
}
schemes.push(format!("{}:", scheme));
}
}
@@ -49,11 +54,19 @@ fn disk_paths() -> Result<Vec<(String, u64)>, String> {
match fs::read_dir(&scheme) {
Ok(entries) => for entry_res in entries {
if let Ok(entry) = entry_res {
if let Ok(path) = entry.path().into_os_string().into_string() {
if let Ok(metadata) = entry.metadata() {
let size = metadata.len();
if size > 0 {
paths.push((path, size));
if let Ok(file_name) = entry.file_name().into_string() {
if file_name.contains('p') {
// Skip partitions
continue;
}
if let Ok(path) = entry.path().into_os_string().into_string() {
if let Ok(metadata) = entry.metadata() {
let size = metadata.len();
if size > 0 {
//TODO: check if root redoxfs
paths.push((path, size));
}
}
}
}