Update WIM structs
This commit is contained in:
parent
94faae27ac
commit
69c3feb838
3 changed files with 26 additions and 7 deletions
|
|
@ -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",
|
||||
)))?;
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,13 +48,13 @@ static WIN_BUILDS: LazyLock<HashMap<&str, &str>> = LazyLock::new(|| {
|
|||
});
|
||||
|
||||
#[derive(Debug)]
|
||||
struct WimFile<'a> {
|
||||
pub struct WimFile<'a> {
|
||||
path: &'a Path,
|
||||
images: Vec<WimImage>,
|
||||
}
|
||||
|
||||
#[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<WimFile<'a>>,
|
||||
pub local: Vec<WimFile<'a>>,
|
||||
pub network: Vec<WimFile<'a>>,
|
||||
}
|
||||
|
||||
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<File> {
|
||||
|
|
@ -200,13 +206,13 @@ fn parse_wim_file(wim_file: &str) -> std::io::Result<WimFile<'_>> {
|
|||
// 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}");
|
||||
|
|
|
|||
Loading…
Reference in a new issue