[PATCH pve-storage v1 18/54] api: status: use helper from common module to get content directory

Max R. Carrara
2026-04-22T11:18:06Z

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 <m.carrara@proxmox.com>
---
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 b9e949ff..742596d4 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);

@@ -608,7 +611,6 @@ __PACKAGE__->register_method({

my $filename = PVE::Storage::normalize_content_filename($param->{filename});

- my $path;
my $is_ova = 0;
my $image_format;

@@ -616,12 +618,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$!
@@ -635,10 +635,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);

@@ -840,7 +840,6 @@ __PACKAGE__->register_method({

my $filename = PVE::Storage::normalize_content_filename($param->{filename});

- my $path;
my $is_ova = 0;
my $image_format;

@@ -848,12 +847,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$!
@@ -867,10 +864,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