From d81a9aea7b50556741699d2fcb5ab3e463f1b175 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Mon, 5 Jun 2023 11:17:27 +0200 Subject: [PATCH] plugin: simplify and fix create-base-path vs mkdir logic In the previous code, if `create-base-path` was explicitly set to false, it would be treated the same as if it was undef, falling through to whatever 'mkdir' was. Instead, the new options should always be preferred, and the logic can be simplified to a single line. Here's the table showing the difference, 'u' being 'undef': config: mkdir: u 0 1 u 0 1 u 0 1 create: u u u 0 0 0 1 1 1 ========================= mkpath: old: 1 0 1 0 0 1 1 1 1 new: 1 0 1 0 0 0 1 1 1 Signed-off-by: Wolfgang Bumiller --- src/PVE/Storage/Plugin.pm | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/PVE/Storage/Plugin.pm b/src/PVE/Storage/Plugin.pm index 34d830e..1f0382d 100644 --- a/src/PVE/Storage/Plugin.pm +++ b/src/PVE/Storage/Plugin.pm @@ -1707,15 +1707,9 @@ sub config_aware_base_mkdir { my ($class, $scfg, $path) = @_; # FIXME the mkdir parameter is deprecated and create-base-path should be used - my $mkpath = 0; - if (!defined($scfg->{'create-base-path'}) && !defined($scfg->{mkdir})) { - $mkpath = 1; - } elsif (defined($scfg->{'create-base-path'}) && $scfg->{'create-base-path'}) { - $mkpath = 1; - } elsif ($scfg->{mkdir}) { - $mkpath = 1; + if ($scfg->{'create-base-path'} // $scfg->{mkdir} // 1) { + mkpath($path); } - mkpath $path if $mkpath; } 1;