From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id CE8241FF0AB for ; Wed, 23 Sep 2026 17:09:03 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id E51FD217FF; Wed, 23 Sep 2026 17:07:07 +0200 (CEST) From: "Max R. Carrara" To: pve-devel@lists.proxmox.com Subject: [PATCH pve-storage v2 18/50] api: status: use helper from common module to get content directory Date: Wed, 23 Sep 2026 17:05:32 +0200 Message-ID: <20260923150606.531239-19-m.carrara@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260923150606.531239-1-m.carrara@proxmox.com> References: <20260923150606.531239-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: 1790176004466 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.438 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust 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: F24MQJNKHFN6HHG7HPQU2J5CJ32HTACU X-Message-ID-Hash: F24MQJNKHFN6HHG7HPQU2J5CJ32HTACU 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: In the subroutines for the upload / download_url API methods, use the `plugin_get_vtype_subdir()` helper from `PVE::Storage::Common` to obtain the sub-directory for the provided content type (vtype), instead of doing that within the if-elsif chains. Signed-off-by: Max R. Carrara --- src/PVE/API2/Storage/Status.pm | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/PVE/API2/Storage/Status.pm b/src/PVE/API2/Storage/Status.pm index 40729465..09a37f4b 100644 --- a/src/PVE/API2/Storage/Status.pm +++ b/src/PVE/API2/Storage/Status.pm @@ -20,6 +20,9 @@ use PVE::API2::Storage::Content; use PVE::API2::Storage::FileRestore; use PVE::API2::Storage::PruneBackups; use PVE::Storage; +use PVE::Storage::Common qw( + plugin_get_vtype_subdir +); use base qw(PVE::RESTHandler); @@ -611,7 +614,6 @@ __PACKAGE__->register_method({ my $filename = PVE::Storage::normalize_content_filename($param->{filename}); - my $path; my $is_ova = 0; my $image_format; @@ -619,12 +621,10 @@ __PACKAGE__->register_method({ if ($filename !~ m![^/]+$PVE::Storage::ISO_EXT_RE_0$!) { raise_param_exc({ filename => "wrong file extension" }); } - $path = PVE::Storage::get_iso_dir($cfg, $storage); } elsif ($content eq 'vztmpl') { if ($filename !~ m![^/]+$PVE::Storage::VZTMPL_EXT_RE_1$!) { raise_param_exc({ filename => "wrong file extension" }); } - $path = PVE::Storage::get_vztmpl_dir($cfg, $storage); } elsif ($content eq 'import') { if ($filename !~ m!${PVE::Storage::SAFE_CHAR_CLASS_RE}+$PVE::Storage::UPLOAD_IMPORT_EXT_RE_1$! @@ -638,10 +638,10 @@ __PACKAGE__->register_method({ } else { $image_format = $format; } - - $path = PVE::Storage::get_import_dir($cfg, $storage); } + my $path = plugin_get_vtype_subdir($scfg, $content); + my $dest = "$path/$filename"; my $dirname = dirname($dest); @@ -843,7 +843,6 @@ __PACKAGE__->register_method({ my $filename = PVE::Storage::normalize_content_filename($param->{filename}); - my $path; my $is_ova = 0; my $image_format; @@ -851,12 +850,10 @@ __PACKAGE__->register_method({ if ($filename !~ m![^/]+$PVE::Storage::ISO_EXT_RE_0$!) { raise_param_exc({ filename => "wrong file extension" }); } - $path = PVE::Storage::get_iso_dir($cfg, $storage); } elsif ($content eq 'vztmpl') { if ($filename !~ m![^/]+$PVE::Storage::VZTMPL_EXT_RE_1$!) { raise_param_exc({ filename => "wrong file extension" }); } - $path = PVE::Storage::get_vztmpl_dir($cfg, $storage); } elsif ($content eq 'import') { if ($filename !~ m!${PVE::Storage::SAFE_CHAR_CLASS_RE}+$PVE::Storage::UPLOAD_IMPORT_EXT_RE_1$! @@ -870,10 +867,10 @@ __PACKAGE__->register_method({ } else { $image_format = $format; } - - $path = PVE::Storage::get_import_dir($cfg, $storage); } + my $path = plugin_get_vtype_subdir($scfg, $content); + PVE::Storage::activate_storage($cfg, $storage); File::Path::make_path($path); -- 2.47.3