diff --git a/PVE/Storage.pm b/PVE/Storage.pm index 7314085..8d904d7 100755 --- a/PVE/Storage.pm +++ b/PVE/Storage.pm @@ -129,6 +129,28 @@ sub lock_storage_config { } } +# FIXME remove maxfiles for PVE 7.0 +my $convert_maxfiles_to_prune_backups = sub { + my ($scfg) = @_; + + return if !$scfg; + + my $maxfiles = delete $scfg->{maxfiles}; + + if (!defined($scfg->{'prune-backups'}) && defined($maxfiles)) { + my $prune_backups; + if ($maxfiles) { + $prune_backups = { 'keep-last' => $maxfiles }; + } else { # maxfiles 0 means no limit + $prune_backups = { 'keep-all' => 1 }; + } + $scfg->{'prune-backups'} = PVE::JSONSchema::print_property_string( + $prune_backups, + 'prune-backups' + ); + } +}; + sub storage_config { my ($cfg, $storeid, $noerr) = @_; @@ -138,6 +160,8 @@ sub storage_config { die "storage '$storeid' does not exist\n" if (!$noerr && !$scfg); + $convert_maxfiles_to_prune_backups->($scfg); + return $scfg; }