mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-02-25 03:44:52 +00:00
fhem.pl: clean up HandleArchiving (Forum #133961)
git-svn-id: https://svn.fhem.de/fhem/trunk@27750 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
254fdd347d
commit
587eb67703
10
fhem/fhem.pl
10
fhem/fhem.pl
@ -1447,9 +1447,9 @@ OpenLogfile($)
|
|||||||
open($LOG, '>&STDOUT') || die "Can't dup stdout: $!";
|
open($LOG, '>&STDOUT') || die "Can't dup stdout: $!";
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
HandleArchiving($defs{global}) if($defs{global}{currentlogfile});
|
|
||||||
$defs{global}{currentlogfile} = $param;
|
$defs{global}{currentlogfile} = $param;
|
||||||
$defs{global}{logfile} = $attr{global}{logfile};
|
$defs{global}{logfile} = $attr{global}{logfile};
|
||||||
|
HandleArchiving($defs{global});
|
||||||
|
|
||||||
restoreDir_mkDir($currlogfile=~m,^/,? "":".", $currlogfile, 1);
|
restoreDir_mkDir($currlogfile=~m,^/,? "":".", $currlogfile, 1);
|
||||||
open($LOG, ">>$currlogfile") || return("Can't open $currlogfile: $!");
|
open($LOG, ">>$currlogfile") || return("Can't open $currlogfile: $!");
|
||||||
@ -4110,8 +4110,6 @@ HandleArchiving($;$)
|
|||||||
my $ard = $attr{$ln}{archivedir};
|
my $ard = $attr{$ln}{archivedir};
|
||||||
return if(!defined($nra));
|
return if(!defined($nra));
|
||||||
|
|
||||||
$nra++ if($ln eq "global"); # Forum #61450
|
|
||||||
|
|
||||||
# If nrarchive is set, then check the last files:
|
# If nrarchive is set, then check the last files:
|
||||||
# Get a list of files:
|
# Get a list of files:
|
||||||
|
|
||||||
@ -4123,16 +4121,18 @@ HandleArchiving($;$)
|
|||||||
}
|
}
|
||||||
|
|
||||||
$file =~ s/%./.+/g;
|
$file =~ s/%./.+/g;
|
||||||
|
my $clf = $log->{currentlogfile};
|
||||||
|
$clf = $2 if($clf =~ m,^(.+)/([^/]+)$,);
|
||||||
|
|
||||||
my @t = localtime(gettimeofday());
|
my @t = localtime(gettimeofday());
|
||||||
$dir = ResolveDateWildcards($dir, @t);
|
$dir = ResolveDateWildcards($dir, @t);
|
||||||
return if(!opendir(DH, $dir));
|
return if(!opendir(DH, $dir));
|
||||||
my @files = sort grep {/^$file$/} readdir(DH);
|
my @files = sort grep {$_ =~ m/^$file$/ && $_ ne $clf } readdir(DH);
|
||||||
@files = sort { (stat("$dir/$a"))[9] <=> (stat("$dir/$b"))[9] } @files
|
@files = sort { (stat("$dir/$a"))[9] <=> (stat("$dir/$b"))[9] } @files
|
||||||
if(AttrVal("global", "archivesort", "alphanum") eq "timestamp");
|
if(AttrVal("global", "archivesort", "alphanum") eq "timestamp");
|
||||||
closedir(DH);
|
closedir(DH);
|
||||||
|
|
||||||
my $max = int(@files)-$nra;
|
my $max = int(@files)-$nra;
|
||||||
$max-- if($flogInitial);
|
|
||||||
for(my $i = 0; $i < $max; $i++) {
|
for(my $i = 0; $i < $max; $i++) {
|
||||||
if($ard) {
|
if($ard) {
|
||||||
Log 2, "Moving $files[$i] to $ard";
|
Log 2, "Moving $files[$i] to $ard";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user