prune mark: keep all if all prune options are zero/missing

as an additional safety measure. And add some tests.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
This commit is contained in:
Fabian Ebner
2020-11-13 14:08:54 +01:00
committed by Thomas Lamprecht
parent 14c922b7da
commit f514181d28
2 changed files with 47 additions and 0 deletions

View File

@ -1622,6 +1622,13 @@ my $prune_mark = sub {
sub prune_mark_backup_group {
my ($backup_group, $keep) = @_;
if (!scalar(grep {$_ > 0} values %{$keep})) {
foreach my $prune_entry (@{$backup_group}) {
$prune_entry->{mark} = 'keep';
}
return;
}
my $prune_list = [ sort { $b->{ctime} <=> $a->{ctime} } @{$backup_group} ];
$prune_mark->($prune_list, $keep->{'keep-last'}, sub {