]> git.proxmox.com Git - pve-storage.git/commitdiff
fix prune-backups validation (again)
authorFabian Ebner <f.ebner@proxmox.com>
Fri, 10 Sep 2021 09:37:18 +0000 (11:37 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 10 Sep 2021 12:16:26 +0000 (14:16 +0200)
Commit a000e26ce7d30ba2b938402164a9a15e66dd123e caused a test failure
in pve-manager, because now 'keep-all=0' is not thrown out upon
validation anymore. Fix the issue the commit addressed differently,
by simply creating a copy of the (shallow) hash first, and using
the logic from before the commit.

Reported-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
PVE/Storage/Plugin.pm

index 870091d5bb216bf8003494f25e617bfed673ce99..417d1fdcfac30ba7a180e06c3ae0d024a4dc7b93 100644 (file)
@@ -93,16 +93,17 @@ PVE::JSONSchema::register_format('prune-backups', $prune_backups_format, \&valid
 sub validate_prune_backups {
     my ($prune_backups) = @_;
 
-    my @positive_opts =
-       grep { $_ ne 'keep-all' && $prune_backups->{$_} > 0 } keys $prune_backups->%*;
+    my $res = { $prune_backups->%* };
 
-    if (scalar(@positive_opts) == 0) {
-       $prune_backups = { 'keep-all' => 1 };
-    } elsif ($prune_backups->{'keep-all'}) {
+    my $keep_all = delete $res->{'keep-all'};
+
+    if (scalar(grep { $_ > 0 } values %{$res}) == 0) {
+       $res = { 'keep-all' => 1 };
+    } elsif ($keep_all) {
        die "keep-all cannot be set together with other options.\n";
     }
 
-    return $prune_backups;
+    return $res;
 }
 register_standard_option('prune-backups', {
     description => "The retention options with shorter intervals are processed first " .