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:
@ -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;
|
||||
|
||||
Reference in New Issue
Block a user