5
0
mirror of git://git.proxmox.com/git/pve-storage.git synced 2024-12-22 13:34:16 +03:00

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 <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2023-06-05 11:17:27 +02:00
parent 7c242295c9
commit d81a9aea7b

View File

@ -1707,15 +1707,9 @@ sub config_aware_base_mkdir {
my ($class, $scfg, $path) = @_; my ($class, $scfg, $path) = @_;
# FIXME the mkdir parameter is deprecated and create-base-path should be used # FIXME the mkdir parameter is deprecated and create-base-path should be used
my $mkpath = 0; if ($scfg->{'create-base-path'} // $scfg->{mkdir} // 1) {
if (!defined($scfg->{'create-base-path'}) && !defined($scfg->{mkdir})) { mkpath($path);
$mkpath = 1;
} elsif (defined($scfg->{'create-base-path'}) && $scfg->{'create-base-path'}) {
$mkpath = 1;
} elsif ($scfg->{mkdir}) {
$mkpath = 1;
} }
mkpath $path if $mkpath;
} }
1; 1;