Commit
b64dd8c8a56c424b4cfe8cb8ef0841e49ba38c03 hard-coded 0 as the default
for maxfiles in the --storage case, but the actual default should be the
value from read_vzdump_defaults(), which obtains the value from
/etc/vzdump.conf or the VZDump schema if the value has not been modified in
that file. The initial default from the schema is 1, not 0.
Tested on PVE 6.1 to verify that behavior.
Move the sanity check for zero-ness to where we have the final value for
maxfiles. Like this, we also have an implicit definedness check and more
importantly, it is more future-proof in case we ever allow maxfiles 0 in the
VZDump schema itself.
Also, force conversion to int to be extra safe.
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
if (!defined($opts->{'prune-backups'}) && !defined($opts->{maxfiles})) {
$opts->{'prune-backups'} = $info->{'prune-backups'};
- $opts->{maxfiles} = $info->{maxfiles} // 0;
- if ($opts->{maxfiles} == 0) {
- # zero means keep all, so avoid triggering any remove code path to be safe
- $opts->{remove} = 0;
- }
+ $opts->{maxfiles} = $info->{maxfiles};
}
}
} elsif ($opts->{dumpdir}) {
if (!defined($opts->{'prune-backups'})) {
my $maxfiles = delete $opts->{maxfiles} // $defaults->{maxfiles};
- $opts->{'prune-backups'} = { 'keep-last' => $maxfiles } if $maxfiles;
+ $maxfiles = int($maxfiles); # shouldn't be necessary, but be safe
+ if ($maxfiles) {
+ $opts->{'prune-backups'} = { 'keep-last' => $maxfiles };
+ } else {
+ # maxfiles being zero means keep all, so avoid triggering any remove code path to be safe
+ $opts->{remove} = 0;
+ }
}
if ($opts->{tmpdir} && ! -d $opts->{tmpdir}) {