From 41a656af92a4c1f02639931b32543a331bf83575 Mon Sep 17 00:00:00 2001
From: Jeremy Soller <jackpot51@gmail.com>
Date: Thu, 12 Jan 2023 08:50:04 -0700
Subject: [PATCH] Ignore live disks and partitions in TUI

---
 src/bin/installer_tui.rs | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/src/bin/installer_tui.rs b/src/bin/installer_tui.rs
index e88450f..38c3140 100644
--- a/src/bin/installer_tui.rs
+++ b/src/bin/installer_tui.rs
@@ -35,6 +35,11 @@ fn disk_paths(paths: &mut Vec<(String, u64)>) {
                 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));
                     }
                 }
@@ -53,11 +58,18 @@ fn disk_paths(paths: &mut Vec<(String, u64)>) {
             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 {
+                                        paths.push((path, size));
+                                    }
                                 }
                             }
                         }
-- 
GitLab