From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id D73FD1FF13B for ; Wed, 22 Apr 2026 13:19:02 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 4C39E19A5A; Wed, 22 Apr 2026 13:15:02 +0200 (CEST) From: "Max R. Carrara" To: pve-devel@lists.proxmox.com Subject: [PATCH pve-storage v1 32/54] api: status: simplify recently added parsing helper for file transfers Date: Wed, 22 Apr 2026 13:12:58 +0200 Message-ID: <20260422111322.257380-33-m.carrara@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260422111322.257380-1-m.carrara@proxmox.com> References: <20260422111322.257380-1-m.carrara@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1776856349818 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.084 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 Message-ID-Hash: CWBM6245BSBU6E64Z4YNLJDNNLIDUCOS X-Message-ID-Hash: CWBM6245BSBU6E64Z4YNLJDNNLIDUCOS X-MailFrom: m.carrara@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Since we already assert whether we can transfer files for a given volume type using the `assert_can_transfer_files()` helper, and also raise an exception if parsing fails, handling the parsing of each volume type individually is not necessary anymore. Therefore, pull out the common parts of the branches for individual volume types. Retain only the special case for the `import` type where we do not accept `.ovf` files. Signed-off-by: Max R. Carrara --- src/PVE/API2/Storage/Status.pm | 40 ++++++---------------------------- 1 file changed, 7 insertions(+), 33 deletions(-) diff --git a/src/PVE/API2/Storage/Status.pm b/src/PVE/API2/Storage/Status.pm index b578a1ed..bff59b66 100644 --- a/src/PVE/API2/Storage/Status.pm +++ b/src/PVE/API2/Storage/Status.pm @@ -73,45 +73,19 @@ my sub assert_can_transfer_files : prototype($$$) { my sub parse_transferred_file_path_extension : prototype($$) { my ($path, $vtype) = @_; - if ($vtype eq 'iso') { - my $parts = parse_path_as_volname_parts($path, $vtype); + my $parts = parse_path_as_volname_parts($path, $vtype); - if (!defined($parts)) { - raise_param_exc({ filename => "wrong file extension" }); - } - - my $ext = $parts->{ext}; - return $ext; + if (!defined($parts)) { + raise_param_exc({ filename => "invalid filename or wrong file extension" }); } - if ($vtype eq 'vztmpl') { - my $parts = parse_path_as_volname_parts($path, $vtype); + my $ext = $parts->{ext}; - if (!defined($parts)) { - raise_param_exc({ filename => "wrong file extension" }); - } - - my $ext = $parts->{ext}; - return $ext; + if ($vtype eq 'import' && $ext eq 'ovf') { + raise_param_exc({ filename => "wrong file extension" }); } - if ($vtype eq 'import') { - my $parts = parse_path_as_volname_parts($path, $vtype); - - if (!defined($parts)) { - raise_param_exc({ filename => "invalid filename or wrong extension" }); - } - - my $ext = $parts->{ext}; - - if ($ext eq 'ovf') { - raise_param_exc({ filename => "wrong file extension" }); - } - - return $ext; - } - - die "upload / download: failed to parse '$path' - unhandled content type '$vtype'\n"; + return $ext; } my sub assert_file_transfer_contents_valid : prototype($$$) { -- 2.47.3