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 3EB6D1FF0AA for ; Tue, 17 Nov 2026 21:42:41 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 8D810218A6; Tue, 17 Nov 2026 21:40:55 +0100 (CET) From: "Max R. Carrara" To: pve-devel@lists.proxmox.com Subject: [PATCH pve-storage v3 17/51] api: status: use get_subdir helper method to get content directory Date: Tue, 17 Nov 2026 21:38:49 +0100 Message-ID: <20261117203953.913035-18-m.carrara@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261117203953.913035-1-m.carrara@proxmox.com> References: <20261117203953.913035-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: 1794948029170 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.262 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: ZPFMG4JGX6663G3EVVB6VCJMTKDBT2GD X-Message-ID-Hash: ZPFMG4JGX6663G3EVVB6VCJMTKDBT2GD 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 CC: Wolfgang Bumiller X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Instead of calling the dedicated `get_$VTYPE_dir()` functions from PVE::Storage, call `$plugin->get_subdir()` directly. Mark it with a FIXME to replace it with `plugin_get_vtype_subdir()` from the common module in the future. There is IMO no reason to call a separate sub for each vtype here, and it also doesn't split the declaration of `$path` from its assignment. We may want to consider replacing `get_iso_dir()` and related subs with a single subroutine instead as well at some point in the future. When something calls `get_iso_dir()` for example, that call site obviously already knows what vtype it is fetching the subdirectory for. Signed-off-by: Max R. Carrara --- src/PVE/API2/Storage/Status.pm | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/PVE/API2/Storage/Status.pm b/src/PVE/API2/Storage/Status.pm index a9f902f9..9fb16888 100644 --- a/src/PVE/API2/Storage/Status.pm +++ b/src/PVE/API2/Storage/Status.pm @@ -610,41 +610,41 @@ __PACKAGE__->register_method({ my $size = -s $tmpfilename; die "temporary file '$tmpfilename' does not exist\n" if !defined($size); my $filename = PVE::Storage::normalize_content_filename($param->{filename}); - my $path; my $is_ova = 0; my $image_format; if ($content eq 'iso') { 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$! ) { raise_param_exc({ filename => "invalid filename or wrong extension" }); } my $format = $1; if ($format eq 'ova') { $is_ova = 1; } else { $image_format = $format; } - - $path = PVE::Storage::get_import_dir($cfg, $storage); } + # FIXME: Call plugin_get_vtype_subdir() instead of + # $plugin->get_subdir() on the next APIAGE reset. + my $plugin = PVE::Storage::Plugin->lookup($scfg->{type}); + my $path = $plugin->get_subdir($scfg, $content); + my $dest = "$path/$filename"; my $dirname = dirname($dest); # best effort to match apl_download behaviour chmod 0644, $tmpfilename; @@ -838,41 +838,41 @@ __PACKAGE__->register_method({ assert_can_transfer_files($scfg, $storage, $content); my $filename = PVE::Storage::normalize_content_filename($param->{filename}); - my $path; my $is_ova = 0; my $image_format; if ($content eq 'iso') { 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$! ) { raise_param_exc({ filename => "invalid filename or wrong extension" }); } my $format = $1; if ($format eq 'ova') { $is_ova = 1; } else { $image_format = $format; } - - $path = PVE::Storage::get_import_dir($cfg, $storage); } + # FIXME: Call plugin_get_vtype_subdir() instead of + # $plugin->get_subdir() on the next APIAGE reset. + my $plugin = PVE::Storage::Plugin->lookup($scfg->{type}); + my $path = $plugin->get_subdir($scfg, $content); + PVE::Storage::activate_storage($cfg, $storage); File::Path::make_path($path); my $dccfg = PVE::Cluster::cfs_read_file('datacenter.cfg'); my $opts = { -- 2.47.3