[PATCH pve-storage v1 30/54] plugin: simplify recently refactored logic in get_subdir_files helper

Max R. Carrara
2026-04-22T11:16:09Z

Pull out the common pieces of the if-clauses that handle individual
volume types.

Do not strip the volume type subdirectory from the beginning of the
current path anymore, because that is handled by the
`parse_path_as_volid_parts()` parsing function, which left `$filename`
unused.

Signed-off-by: Max R. Carrara <m.carrara@proxmox.com>
---
src/PVE/Storage/Plugin.pm | 23 ++---------------------
1 file changed, 2 insertions(+), 21 deletions(-)

diff --git a/src/PVE/Storage/Plugin.pm b/src/PVE/Storage/Plugin.pm
index 376e2515..65e0869b 100644
--- a/src/PVE/Storage/Plugin.pm
+++ b/src/PVE/Storage/Plugin.pm
@@ -1677,17 +1677,10 @@ my sub get_subdir_files {
my $get_subdir_file_info = sub {
my ($path, $st) = @_;

- # Strip the vtype subdir from beginning of the current path
- # so that we don't have to take it into account when parsing the file name
- my $filename = $path;
- if ($filename !~ s!^\Q$vtype_subdir\E!!) {
- return;
- }
+ my $parts = parse_path_as_volid_parts($storeid, $scfg, $path, $vtype);
+ return if !defined($parts);

if ($vtype eq 'iso') {
- my $parts = parse_path_as_volid_parts($storeid, $scfg, $path, $vtype);
- return if !defined($parts);
-
return {
volid => $parts->{volid},
format => 'iso', # always 'iso' even if we have a file ending in .img
@@ -1695,9 +1688,6 @@ my sub get_subdir_files {
}

if ($vtype eq 'vztmpl') {
- my $parts = parse_path_as_volid_parts($storeid, $scfg, $path, $vtype);
- return if !defined($parts);
-
my ($ext, $ext_compression) = $parts->@{qw(ext ext-compression)};
my $format = $ext eq 'tar' ? $ext : ('t' . $ext_compression);

@@ -1708,9 +1698,6 @@ my sub get_subdir_files {
}

if ($vtype eq 'backup') {
- my $parts = parse_path_as_volid_parts($storeid, $scfg, $path, $vtype);
- return if !defined($parts);
-
my $format = $parts->{ext};
my $volume_path = $parts->{path};

@@ -1748,9 +1735,6 @@ my sub get_subdir_files {
}

if ($vtype eq 'snippets') {
- my $parts = parse_path_as_volid_parts($storeid, $scfg, $path, $vtype);
- return if !defined($parts);
-
return {
volid => $parts->{volid},
format => 'snippet',
@@ -1758,9 +1742,6 @@ my sub get_subdir_files {
}

if ($vtype eq 'import') {
- my $parts = parse_path_as_volid_parts($storeid, $scfg, $path, $vtype);
- return if !defined($parts);
-
return {
volid => $parts->{volid},
format => $parts->{ext},
--
2.47.3