[pve-devel] [PATCH installer 2/3] set correct maximum for hdsize input
Folke Gleumes
f.gleumes at proxmox.com
Tue Nov 21 14:20:20 CET 2023
previously, when opening the dialog multiple times, the maximum was
determined by the previous set value, not the maxium possible for the
storage
Signed-off-by: Folke Gleumes <f.gleumes at proxmox.com>
---
proxinstall | 25 +++++++++++++++++--------
1 file changed, 17 insertions(+), 8 deletions(-)
diff --git a/proxinstall b/proxinstall
index cf8f510..4fc31f8 100755
--- a/proxinstall
+++ b/proxinstall
@@ -985,14 +985,11 @@ my $create_label_widget_grid = sub {
return $grid;
};
-# only relevant for raid with its multipl diskX to diskY mappings.
-my $get_selected_hdsize = sub {
- my $hdsize = shift;
- return $hdsize if defined($hdsize);
-
- # compute the smallest disk size of the actually selected disks
+# only returns a value when using raid, undef otherwise
+my $get_max_hdsize = sub {
my $cached_disks = get_cached_disks();
my $disk_count = scalar(@$cached_disks);
+ my $hdsize;
for (my $i = 0; $i < $disk_count; $i++) {
my $cur_hd = $gtk_state->{disk_selection}->{$i} // next;
my $disksize = int(@$cur_hd[2] / (2 * 1024 * 1024.0)); # size in GB
@@ -1000,6 +997,16 @@ my $get_selected_hdsize = sub {
$hdsize = $disksize if $disksize < $hdsize;
}
+ return $hdsize;
+};
+
+# only relevant for raid with its multipl diskX to diskY mappings.
+my $get_selected_hdsize = sub {
+ my $hdsize = shift;
+ return $hdsize if defined($hdsize);
+
+ $hdsize = $get_max_hdsize->();
+
if (my $cfg_hdsize = Proxmox::Install::Config::get_hdsize()) {
# had the dialog open previously and set an even lower size than the disk selection allows
$hdsize = $cfg_hdsize if $cfg_hdsize < $hdsize;
@@ -1011,17 +1018,19 @@ my sub update_hdsize_adjustment {
my ($adjustment, $hdsize) = @_;
$hdsize = $get_selected_hdsize->($hdsize);
+ my $max_hdsize = $get_max_hdsize->() // $hdsize;
# expect that lower = 0 and step increments = 1 still are valid
- $adjustment->set_upper($hdsize + 1);
+ $adjustment->set_upper($max_hdsize + 1);
$adjustment->set_value($hdsize);
}
my sub create_hdsize_adjustment {
my ($hdsize) = @_;
$hdsize = $get_selected_hdsize->($hdsize);
+ my $max_hdsize = $get_max_hdsize->() // $hdsize;
my $cfg_hdsize = Proxmox::Install::Config::get_hdsize();
# params are: initial value, lower, upper, step increment, page increment, page size
- return Gtk3::Adjustment->new($cfg_hdsize || $hdsize, 0, $hdsize+1, 1, 1, 1);
+ return Gtk3::Adjustment->new($cfg_hdsize || $hdsize, 0, $max_hdsize+1, 1, 1, 1);
}
my sub get_hdsize_spin_button {
--
2.39.2
More information about the pve-devel
mailing list