2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-10 03:06:37 +00:00

fhem.pl/01_FHEMWEB.pm: sort logfiles after timestamp not name (Forum #66896)

git-svn-id: https://svn.fhem.de/fhem/trunk@13400 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2017-02-12 15:47:56 +00:00
parent 97f46e33e7
commit a8a2fa5d24
2 changed files with 7 additions and 5 deletions

View File

@ -20,7 +20,7 @@ sub FW_digestCgi($);
sub FW_directNotify($@); sub FW_directNotify($@);
sub FW_doDetail($); sub FW_doDetail($);
sub FW_fatal($); sub FW_fatal($);
sub FW_fileList($); sub FW_fileList($;$);
sub FW_htmlEscape($); sub FW_htmlEscape($);
sub FW_iconName($); sub FW_iconName($);
sub FW_iconPath($); sub FW_iconPath($);
@ -1523,7 +1523,7 @@ FW_roomOverview($)
my $lfn = "Logfile"; my $lfn = "Logfile";
if($defs{$lfn}) { # Add the current Logfile to the list if defined if($defs{$lfn}) { # Add the current Logfile to the list if defined
my @l = FW_fileList($defs{$lfn}{logfile}); my @l = FW_fileList($defs{$lfn}{logfile},1);
my $fn = pop @l; my $fn = pop @l;
splice @list, 4,0, ("Logfile", splice @list, 4,0, ("Logfile",
"$FW_ME/FileLog_logWrapper?dev=$lfn&type=text&file=$fn"); "$FW_ME/FileLog_logWrapper?dev=$lfn&type=text&file=$fn");
@ -1837,9 +1837,9 @@ FW_parseColumns()
################# #################
# return a sorted list of actual files for a given regexp # return a sorted list of actual files for a given regexp
sub sub
FW_fileList($) FW_fileList($;$)
{ {
my ($fname) = @_; my ($fname,$mtime) = @_;
$fname =~ m,^(.*)/([^/]*)$,; # Split into dir and file $fname =~ m,^(.*)/([^/]*)$,; # Split into dir and file
my ($dir,$re) = ($1, $2); my ($dir,$re) = ($1, $2);
return $fname if(!$re); return $fname if(!$re);
@ -1853,6 +1853,7 @@ FW_fileList($)
push(@ret, $f); push(@ret, $f);
} }
closedir(DH); closedir(DH);
return sort { (stat("$dir/$a"))[9] cmp (stat("$dir/$b"))[9] } @ret if($mtime);
@ret = cfgDB_FW_fileList($dir,$re,@ret) if (configDBUsed()); @ret = cfgDB_FW_fileList($dir,$re,@ret) if (configDBUsed());
return sort @ret; return sort @ret;
} }

View File

@ -3447,7 +3447,8 @@ HandleArchiving($;$)
my @t = localtime; my @t = localtime;
$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 { (stat("$dir/$a"))[9] cmp (stat("$dir/$b"))[9] } #66896
grep {/^$file$/} readdir(DH);
closedir(DH); closedir(DH);
my $max = int(@files)-$nra; my $max = int(@files)-$nra;