mirror of https://github.com/schoebel/mars
marsadm: renam _allowed_logdelete() to _min_nondeletable_logfile()
Signed-off-by: Thomas Schoebel-Theuer <tst@1und1.de>
This commit is contained in:
parent
5d3d777b86
commit
7a42f95d6c
|
@ -655,7 +655,7 @@ sub logrotate_res {
|
|||
system("touch $next");
|
||||
}
|
||||
|
||||
sub _allowed_logdelete {
|
||||
sub _min_nondeletable_logfile {
|
||||
my ($cmd, $res) = @_;
|
||||
my $min = -1;
|
||||
my @paths = glob("$mars/resource-$res/replay-*") or ldie "cannot find any replay symlinks\n";
|
||||
|
@ -665,7 +665,7 @@ sub _allowed_logdelete {
|
|||
$nr =~ s/^log-([0-9]+)-.*$/$1/;
|
||||
$min = $nr if ($nr < $min || $min < 0);
|
||||
}
|
||||
lprint "max allowed deletable logfile number: $min\n";
|
||||
lprint "min non-deletable logfile number: $min\n";
|
||||
return $min;
|
||||
}
|
||||
|
||||
|
@ -687,7 +687,7 @@ sub logdelete_res {
|
|||
my ($cmd, $res) = @_;
|
||||
my @paths = glob("$mars/resource-$res/log-*") or ldie "cannot find any logfiles\n";
|
||||
@paths = sort(@paths);
|
||||
my $max = _allowed_logdelete(@_);
|
||||
my $max_deletable = _min_nondeletable_logfile(@_) - 1;
|
||||
|
||||
my $nr = 0;
|
||||
for (;;) {
|
||||
|
@ -695,7 +695,7 @@ sub logdelete_res {
|
|||
last unless $first;
|
||||
$nr = $first;
|
||||
$nr =~ s/^.*log-([0-9]+)-.+$/$1/;
|
||||
last unless $nr < $max;
|
||||
next unless $nr <= $max_deletable;
|
||||
|
||||
lprint "chosen '$first' for deletion\n";
|
||||
|
||||
|
@ -705,7 +705,8 @@ sub logdelete_res {
|
|||
foreach my $versionlink (glob("$mars/resource-$res/version-*")) {
|
||||
my $nrv = $versionlink;
|
||||
$nrv =~ s/^.*\/version-([0-9]+)-.+$/$1/;
|
||||
next unless $nrv < $max - 1;
|
||||
# we need at least one more version link than logfiles for consistency checks
|
||||
next unless $nrv <= $max_deletable - 1;
|
||||
_create_delete($versionlink);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue