From 69c3feb838e90b141579687825991fc785a98ed4 Mon Sep 17 00:00:00 2001 From: 2Shirt <2xShirt@gmail.com> Date: Sat, 8 Nov 2025 17:48:00 -0800 Subject: [PATCH] Update WIM structs --- win_installer/src/app.rs | 5 ++++- win_installer/src/state.rs | 10 ++++++++++ win_installer/src/wim.rs | 18 ++++++++++++------ 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/win_installer/src/app.rs b/win_installer/src/app.rs index da38f04..d9f6e6b 100644 --- a/win_installer/src/app.rs +++ b/win_installer/src/app.rs @@ -102,7 +102,7 @@ impl App<'_> { } let action_tx = self.action_tx.clone(); - action_tx.send(Action::SetMode(Mode::PEMenu))?; + action_tx.send(Action::SetMode(Mode::ScanDisks))?; loop { self.handle_events(&mut tui).await?; self.handle_actions(&mut tui)?; @@ -219,6 +219,9 @@ impl App<'_> { Action::Render => self.render(tui)?, Action::SetMode(mode) => { self.mode = mode; + if self.mode == Mode::ScanDisks { + self.state.reset(); + } self.action_tx.send(Action::UpdateFooter(String::from( "(Enter) to select / (t) for terminal / (p) to power off / (r) to restart", )))?; diff --git a/win_installer/src/state.rs b/win_installer/src/state.rs index 48a0086..a52efd6 100644 --- a/win_installer/src/state.rs +++ b/win_installer/src/state.rs @@ -40,6 +40,16 @@ impl State<'_> { } } + pub fn reset(&mut self) { + self.disk_index_dest = None; + self.part_index_boot = None; + self.wim_file_index = None; + self.wim_image_index = None; + if let Ok(mut sources) = self.wim_sources.lock() { + sources.reset(); + } + } + pub fn scan_drivers(&mut self) { self.driver_list = drivers::scan(); } diff --git a/win_installer/src/wim.rs b/win_installer/src/wim.rs index 96cea57..3d464c0 100644 --- a/win_installer/src/wim.rs +++ b/win_installer/src/wim.rs @@ -48,13 +48,13 @@ static WIN_BUILDS: LazyLock> = LazyLock::new(|| { }); #[derive(Debug)] -struct WimFile<'a> { +pub struct WimFile<'a> { path: &'a Path, images: Vec, } #[derive(Clone, Debug, Default)] -struct WimImage { +pub struct WimImage { build: String, index: String, name: String, @@ -90,13 +90,19 @@ impl fmt::Display for WimImage { #[derive(Debug, Default)] pub struct WimSources<'a> { - files: Vec>, + pub local: Vec>, + pub network: Vec>, } impl WimSources<'_> { pub fn new() -> Self { Default::default() } + + pub fn reset(&mut self) { + self.local.clear(); + self.network.clear(); + } } fn get_wim_xml(wim_file: &str) -> std::io::Result { @@ -200,13 +206,13 @@ fn parse_wim_file(wim_file: &str) -> std::io::Result> { // if let Ok(wim_file) = parse_wim_file("./23H2.wim") // && !wim_file.images.is_empty() // { -// sources.files.push(wim_file); +// sources.local.push(wim_file); // } // if let Ok(wim_file) = parse_wim_file("./24H2.wim") { -// sources.files.push(wim_file); +// sources.local.push(wim_file); // } // dbg!(&sources); -// sources.files.iter().for_each(|f| { +// sources.local.iter().for_each(|f| { // println!("-- {} --", f.path.to_string_lossy()); // f.images.iter().for_each(|i| { // println!("* {i}");