]> git.proxmox.com Git - pve-installer.git/commitdiff
tui: fix passing disk selection, use index
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 20 Jun 2023 19:06:59 +0000 (21:06 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 20 Jun 2023 19:07:04 +0000 (21:07 +0200)
Currently the installer depends on the index to derive the selected
disks, so use that instead of a wishing-how-it-could-be approach.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
proxmox-tui-installer/src/options.rs
proxmox-tui-installer/src/setup.rs

index a436d17be477ae1b48a44f4f8c16751aedcacb3e..39cadd67a90552cd49b5568f11dfb81bb0192406 100644 (file)
@@ -221,6 +221,7 @@ pub enum AdvancedBootdiskOptions {
 
 #[derive(Clone, Debug, Eq, PartialEq)]
 pub struct Disk {
+    pub index: String,
     pub path: String,
     pub model: Option<String>,
     pub size: u64,
@@ -251,13 +252,13 @@ impl From<&Disk> for String {
 
 impl cmp::PartialOrd for Disk {
     fn partial_cmp(&self, other: &Self) -> Option<cmp::Ordering> {
-        self.path.partial_cmp(&other.path)
+        self.index.partial_cmp(&other.index)
     }
 }
 
 impl cmp::Ord for Disk {
     fn cmp(&self, other: &Self) -> cmp::Ordering {
-        self.path.cmp(&other.path)
+        self.index.cmp(&other.index)
     }
 }
 
index 9b2151c7bc3f334a269f13b7ccce8b63f71450f4..0608147abf232f183fdaf4fc6875f37c504959d7 100644 (file)
@@ -183,14 +183,14 @@ impl From<InstallerOptions> for InstallConfig {
                 config.zfs_opts = Some(zfs.clone().into());
 
                 for disk in &options.bootdisk.disks {
-                    config.disk_selection.insert(disk.path.clone(), 1);
+                    config.disk_selection.insert(disk.index.clone(), 1);
                 }
             }
             AdvancedBootdiskOptions::Btrfs(btrfs) => {
                 config.hdsize = btrfs.disk_size;
 
                 for disk in &options.bootdisk.disks {
-                    config.disk_selection.insert(disk.path.clone(), 1);
+                    config.disk_selection.insert(disk.index.clone(), 1);
                 }
             }
         }
@@ -238,7 +238,8 @@ where
     Ok(disks
         .into_iter()
         .map(
-            |(_index, device, size_mb, model, logical_bsize, _syspath)| Disk {
+            |(index, device, size_mb, model, logical_bsize, _syspath)| Disk {
+                index: index.to_string(),
                 size: size_mb * logical_bsize,
                 path: device,
                 model: (!model.is_empty()).then_some(model),