From a14e0a5e95fa472cc08b44a9e92c3a8fca0e35eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= Date: Fri, 19 Jul 2019 13:53:45 +0200 Subject: [PATCH] storage plugin: move get_subdir call MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit since list_volumes is only supposed to be called with filtered content types, this should ensure that get_subdir is only called for plugins that have a defined 'path' property, like the old code in PVE::Storage::template_list did. Signed-off-by: Fabian Grünbichler --- PVE/Storage/Plugin.pm | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/PVE/Storage/Plugin.pm b/PVE/Storage/Plugin.pm index e075a1d..08ec749 100644 --- a/PVE/Storage/Plugin.pm +++ b/PVE/Storage/Plugin.pm @@ -954,18 +954,20 @@ sub list_volumes { foreach my $ct (@$content_types) { my $data; - my $path = $class->get_subdir($scfg, $ct); - if ($ct eq 'images') { $data = $class->list_images($storeid, $scfg, $vmid); - } elsif ($ct eq 'iso' && !defined($vmid)) { - $data = $get_subdir_files->($storeid, $path, 'iso'); - } elsif ($ct eq 'vztmpl'&& !defined($vmid)) { - $data = $get_subdir_files->($storeid, $path, 'vztmpl'); - } elsif ($ct eq 'backup') { - $data = $get_subdir_files->($storeid, $path, 'backup', $vmid); - } elsif ($ct eq 'snippets') { - $data = $get_subdir_files->($storeid, $path, 'snippets'); + } elsif ($scfg->{path}) { + my $path = $class->get_subdir($scfg, $ct); + + if ($ct eq 'iso' && !defined($vmid)) { + $data = $get_subdir_files->($storeid, $path, 'iso'); + } elsif ($ct eq 'vztmpl'&& !defined($vmid)) { + $data = $get_subdir_files->($storeid, $path, 'vztmpl'); + } elsif ($ct eq 'backup') { + $data = $get_subdir_files->($storeid, $path, 'backup', $vmid); + } elsif ($ct eq 'snippets') { + $data = $get_subdir_files->($storeid, $path, 'snippets'); + } } next if !$data;