diff --git a/fhem/FHEM/92_FileLog.pm b/fhem/FHEM/92_FileLog.pm
index 34bac2fcd..f3992e710 100755
--- a/fhem/FHEM/92_FileLog.pm
+++ b/fhem/FHEM/92_FileLog.pm
@@ -39,7 +39,8 @@ FileLog_Initialize($)
$hash->{AttrFn} = "FileLog_Attr";
# logtype is used by the frontend
$hash->{AttrList} = "disable:0,1 disabledForIntervals logtype reformatFn ".
- "nrarchive archivedir archivecmd addStateEvent:0,1";
+ "nrarchive archivedir archivecmd addStateEvent:0,1 ".
+ "archiveCompress";
$hash->{FW_summaryFn} = "FileLog_fhemwebFn";
$hash->{FW_detailFn} = "FileLog_fhemwebFn";
@@ -1202,14 +1203,20 @@ FileLog_regexpFn($$)
shell command (no enclosing " is needed), and each % in the command
will be replaced with the name of the old logfile.
- If this attribute is not set, but nrarchive and/or archivecmd are set,
- then nrarchive old logfiles are kept along the current one while older
- ones are moved to archivedir (or deleted if archivedir is not set).
-
+ If this attribute is not set, but nrarchive is set, then nrarchive old
+ logfiles are kept along the current one while older ones are moved to
+ archivedir (or deleted if archivedir is not set).
+
Note: setting these attributes for the global instance will effect the
FHEM logfile only.
+
+
archiveCompress
+ If nrarchive, archivedir and archiveCompress is set, then the files
+ in the archivedir will be compressed.
+
+
disable
disabledForIntervals
@@ -1486,18 +1493,22 @@ FileLog_regexpFn($$)
shell-Kommando ( eine Einbettung in " ist nicht notwendig), und jedes %
in diesem Befehl wird durch den Namen des alten Logfiles ersetzt.
- Wenn dieses Attribut nicht gesetzt wird, aber dafür nrarchive
- und/oder archivecmd, werden nrarchive viele Logfiles im aktuellen
- Verzeichnis gelassen, und ältere Dateien in das Archivverzeichnis
- (archivedir) verschoben (oder gelöscht, falls kein archivedir
- gesetzt wurde).
+ Wenn dieses Attribut nicht gesetzt wird, aber dafür nrarchive,
+ werden nrarchive viele Logfiles im aktuellen Verzeichnis gelassen, und
+ ältere Dateien in das Archivverzeichnis (archivedir) verschoben
+ (oder gelöscht, falls kein archivedir gesetzt wurde).
Hinweis: Werden diese Attribute als global instance gesetzt, hat das
auschließlich auf das FHEM logfile
- Auswirkungen.
+ Auswirkungen.
+
+ archiveCompress
+ Falls nrarchive, archivedir und archiveCompress gesetzt ist, dann
+ werden die Dateien im archivedir komprimiert abgelegt.
+
disable
addStateEvent
diff --git a/fhem/fhem.pl b/fhem/fhem.pl
index 658f9f342..af7510b04 100755
--- a/fhem/fhem.pl
+++ b/fhem/fhem.pl
@@ -114,7 +114,7 @@ sub getAllGets($);
sub getAllSets($);
sub getUniqueId();
sub latin1ToUtf8($);
-sub myrename($$);
+sub myrename($$$);
sub notifyRegexpChanged($$);
sub readingsBeginUpdate($);
sub readingsBulkUpdate($$$@);
@@ -255,6 +255,7 @@ my @globalAttrList = qw(
apiversion
archivecmd
archivedir
+ archiveCompress
autoload_undefined_devices:1,0
autosave:1,0
backup_before_update
@@ -3121,10 +3122,20 @@ doGlobalDef($)
#####################################
# rename does not work over Filesystems: lets copy it
sub
-myrename($$)
+myrename($$$)
{
- my ($from, $to) = @_;
+ my ($name, $from, $to) = @_;
+ my $ca = AttrVal($name, "archiveCompress", 0);
+ if($ca) {
+ eval { require Compress::Zlib; };
+ if($@) {
+ $ca = 0;
+ Log 1, $@;
+ }
+ }
+ $to .= ".gz" if($ca);
+
if(!open(F, $from)) {
Log(1, "Rename: Cannot open $from: $!");
return;
@@ -3133,8 +3144,18 @@ myrename($$)
Log(1, "Rename: Cannot open $to: $!");
return;
}
- while(my $l = ) {
- print T $l;
+
+ if($ca) {
+ my $d = Compress::Zlib::deflateInit(-WindowBits=>31);
+ my $buf;
+ while(sysread(F,$buf,32768) > 0) {
+ syswrite(T, $d->deflate($buf));
+ }
+ syswrite(T, $d->flush());
+ } else {
+ while(my $l = ) {
+ print T $l;
+ }
}
close(F);
close(T);
@@ -3146,13 +3167,14 @@ myrename($$)
sub
HandleArchiving($;$)
{
- my ($log,$diff) = @_;
+ my ($log,$flogInitial) = @_;
my $ln = $log->{NAME};
return if(!$attr{$ln});
# If there is a command, call that
my $cmd = $attr{$ln}{archivecmd};
if($cmd) {
+ return if($flogInitial); # Forum #41245
$cmd =~ s/%/$log->{currentlogfile}/g;
Log 2, "Archive: calling $cmd";
system($cmd);
@@ -3179,11 +3201,11 @@ HandleArchiving($;$)
closedir(DH);
my $max = int(@files)-$nra;
- $max -= $diff if($diff);
+ $max-- if($flogInitial);
for(my $i = 0; $i < $max; $i++) {
if($ard) {
Log 2, "Moving $files[$i] to $ard";
- myrename("$dir/$files[$i]", "$ard/$files[$i]");
+ myrename($ln, "$dir/$files[$i]", "$ard/$files[$i]");
} else {
Log 2, "Deleting $files[$i]";
unlink("$dir/$files[$i]");