mirror of
https://git.proxmox.com/git/pve-installer
synced 2025-08-12 01:19:01 +00:00
tui: add better error handling to BootdiskOptions::get_values()
Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
This commit is contained in:
parent
fccf6bb019
commit
994c4ff0a7
@ -352,18 +352,19 @@ fn bootdisk_dialog(siv: &mut Cursive) -> InstallerView {
|
||||
BootdiskOptionsView::new(&state.runtime_info.disks, &state.options.bootdisk)
|
||||
.with_name("bootdisk-options"),
|
||||
Box::new(|siv| {
|
||||
let options = siv
|
||||
.call_on_name("bootdisk-options", BootdiskOptionsView::get_values)
|
||||
.flatten();
|
||||
let options = siv.call_on_name("bootdisk-options", BootdiskOptionsView::get_values);
|
||||
|
||||
if let Some(options) = options {
|
||||
siv.with_user_data(|state: &mut InstallerState| {
|
||||
state.options.bootdisk = options;
|
||||
});
|
||||
match options {
|
||||
Some(Ok(options)) => {
|
||||
siv.with_user_data(|state: &mut InstallerState| {
|
||||
state.options.bootdisk = options;
|
||||
});
|
||||
|
||||
switch_to_next_screen(siv, InstallerStep::Timezone, &timezone_dialog);
|
||||
} else {
|
||||
siv.add_layer(Dialog::info("Invalid values"));
|
||||
switch_to_next_screen(siv, InstallerStep::Timezone, &timezone_dialog);
|
||||
}
|
||||
|
||||
Some(Err(err)) => siv.add_layer(Dialog::info(format!("Invalid values: {err}"))),
|
||||
_ => siv.add_layer(Dialog::info("Invalid values")),
|
||||
}
|
||||
}),
|
||||
)
|
||||
|
@ -52,21 +52,22 @@ impl BootdiskOptionsView {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_values(&mut self) -> Option<BootdiskOptions> {
|
||||
pub fn get_values(&mut self) -> Result<BootdiskOptions, String> {
|
||||
let mut options = (*self.advanced_options).clone().into_inner();
|
||||
|
||||
if [FsType::Ext4, FsType::Xfs].contains(&options.fstype) {
|
||||
let disk = self
|
||||
.view
|
||||
.get_child_mut(0)?
|
||||
.downcast_mut::<NamedView<FormView>>()?
|
||||
.get_mut()
|
||||
.get_value::<SelectView<Disk>, _>(0)?;
|
||||
.get_child_mut(0)
|
||||
.and_then(|v| v.downcast_mut::<NamedView<FormView>>())
|
||||
.map(NamedView::<FormView>::get_mut)
|
||||
.and_then(|v| v.get_value::<SelectView<Disk>, _>(0))
|
||||
.ok_or("failed to retrieve filesystem type")?;
|
||||
|
||||
options.disks = vec![disk];
|
||||
}
|
||||
|
||||
Some(options)
|
||||
Ok(options)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user