From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 8B6789BD32 for ; Tue, 21 Nov 2023 14:21:06 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 61980A02B for ; Tue, 21 Nov 2023 14:21:06 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Tue, 21 Nov 2023 14:21:03 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 838A1415BA for ; Tue, 21 Nov 2023 14:21:03 +0100 (CET) From: Folke Gleumes To: pve-devel@lists.proxmox.com Date: Tue, 21 Nov 2023 14:20:20 +0100 Message-Id: <20231121132021.219504-2-f.gleumes@proxmox.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231121132021.219504-1-f.gleumes@proxmox.com> References: <20231121132021.219504-1-f.gleumes@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.018 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - Subject: [pve-devel] [PATCH installer 2/3] set correct maximum for hdsize input X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Nov 2023 13:21:06 -0000 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 --- 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