mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-21 07:56:03 +00:00
98_update.pm: fix loop bugs (Forum #45121)
git-svn-id: https://svn.fhem.de/fhem/trunk@10242 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
b1249a55c8
commit
6a431f1759
@ -24,6 +24,7 @@ my %updDirs;
|
|||||||
my $updArg;
|
my $updArg;
|
||||||
my $mainPgm = "/fhem.pl\$";
|
my $mainPgm = "/fhem.pl\$";
|
||||||
my %upd_connecthash;
|
my %upd_connecthash;
|
||||||
|
my $upd_needJoin;
|
||||||
|
|
||||||
|
|
||||||
########################################
|
########################################
|
||||||
@ -73,7 +74,6 @@ CommandUpdate($$)
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
doUpdateLoop($src, $arg);
|
doUpdateLoop($src, $arg);
|
||||||
HttpUtils_Close(\%upd_connecthash);
|
|
||||||
my $ret = $updRet; $updRet = "";
|
my $ret = $updRet; $updRet = "";
|
||||||
return $ret;
|
return $ret;
|
||||||
|
|
||||||
@ -181,7 +181,6 @@ doUpdateInBackground($)
|
|||||||
*Log = \&update_Log2Event;
|
*Log = \&update_Log2Event;
|
||||||
sleep(2); # Give time for ActivateInform / FHEMWEB / JavaScript
|
sleep(2); # Give time for ActivateInform / FHEMWEB / JavaScript
|
||||||
doUpdateLoop($h->{src}, $h->{arg});
|
doUpdateLoop($h->{src}, $h->{arg});
|
||||||
HttpUtils_Close(\%upd_connecthash);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub
|
sub
|
||||||
@ -189,29 +188,35 @@ doUpdateLoop($$)
|
|||||||
{
|
{
|
||||||
my ($src, $arg) = @_;
|
my ($src, $arg) = @_;
|
||||||
|
|
||||||
doUpdate(1,1, $src, $arg) if($src =~ m/^http.*/);
|
$upd_needJoin = 0;
|
||||||
|
if($src =~ m/^http.*/) {
|
||||||
|
doUpdate(1,1, $src, $arg);
|
||||||
|
HttpUtils_Close(\%upd_connecthash);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
my $mpath = $attr{global}{modpath}."/FHEM/controls.txt";
|
my $mpath = $attr{global}{modpath}."/FHEM/controls.txt";
|
||||||
if(!open(LFH, "$mpath")) {
|
if(!open(LFH, $mpath)) {
|
||||||
my $msg = "Can't open $mpath: $!";
|
my $msg = "Can't open $mpath: $!";
|
||||||
uLog 1, $msg;
|
uLog 1, $msg;
|
||||||
return $msg;
|
return $msg;
|
||||||
}
|
}
|
||||||
|
my @list = <LFH>;
|
||||||
|
close(LFH);
|
||||||
|
chomp @list;
|
||||||
|
|
||||||
my ($max,$curr) = (0,0);
|
my ($max,$curr) = (0,0);
|
||||||
while(my $srcLine = <LFH>) {
|
foreach my $srcLine (@list) {
|
||||||
chomp($srcLine);
|
next if($src && $srcLine !~ m/controls_{$src}/);
|
||||||
continue if($src && $srcLine !~ m/controls_{$src}/);
|
|
||||||
$max++;
|
$max++;
|
||||||
}
|
}
|
||||||
uLog 1, "No source file named controls_$src found" if($src && !$max);
|
uLog 1, "No source file named controls_$src found" if($src && !$max);
|
||||||
|
|
||||||
seek(LFH,0,0);
|
foreach my $srcLine (@list) {
|
||||||
while(my $srcLine = <LFH>) {
|
next if($src && $srcLine !~ m/controls_{$src}/);
|
||||||
chomp($srcLine);
|
|
||||||
continue if($src && $srcLine !~ m/controls_{$src}/);
|
|
||||||
doUpdate(++$curr, $max, $srcLine, $arg);
|
doUpdate(++$curr, $max, $srcLine, $arg);
|
||||||
|
HttpUtils_Close(\%upd_connecthash);
|
||||||
}
|
}
|
||||||
close(LFH);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub
|
sub
|
||||||
@ -267,7 +272,7 @@ doUpdate($$$$)
|
|||||||
$lh{$l[3]}{LEN} = $l[2];
|
$lh{$l[3]}{LEN} = $l[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
my ($canJoin, $needJoin);
|
my $canJoin;
|
||||||
my $cj = "$root/contrib/commandref_join.pl";
|
my $cj = "$root/contrib/commandref_join.pl";
|
||||||
if(-f $cj &&
|
if(-f $cj &&
|
||||||
-f "$root/docs/commandref_frame.html" &&
|
-f "$root/docs/commandref_frame.html" &&
|
||||||
@ -334,7 +339,7 @@ doUpdate($$$$)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$needJoin = 1 if($fName =~ m/commandref_frame/ || $fName =~ m/\d+.*.pm/);
|
$upd_needJoin = 1 if($fName =~ m/commandref_frame/ || $fName=~ m/\d+.*.pm/);
|
||||||
next if($fName =~ m/commandref.*html/ && $fName !~ m/frame/ && $canJoin);
|
next if($fName =~ m/commandref.*html/ && $fName !~ m/frame/ && $canJoin);
|
||||||
|
|
||||||
uLog 1, "List of new / modified files since last update:"
|
uLog 1, "List of new / modified files since last update:"
|
||||||
@ -362,26 +367,22 @@ doUpdate($$$$)
|
|||||||
return if(!upd_writeFile($root, $restoreDir, $fName, $remFile));
|
return if(!upd_writeFile($root, $restoreDir, $fName, $remFile));
|
||||||
}
|
}
|
||||||
|
|
||||||
if($nChanged == 0 && $nSkipped == 0) {
|
uLog 1, "nothing to do..." if($nChanged == 0 && $nSkipped == 0);
|
||||||
uLog 1, "nothing to do...";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(@rl) {
|
if(@rl && ($nChanged || $nSkipped)) {
|
||||||
uLog(1, "");
|
uLog(1, "");
|
||||||
uLog 1, "New entries in the CHANGED file:";
|
uLog 1, "New entries in the CHANGED file:";
|
||||||
map { uLog 1, $_ } @rl;
|
map { uLog 1, $_ } @rl;
|
||||||
}
|
}
|
||||||
return if($arg eq "check");
|
return if($arg eq "check");
|
||||||
|
|
||||||
if($arg eq "all" || $arg eq "force") { # store the controlfile
|
if(($arg eq "all" || $arg eq "force") && ($nChanged || $nSkipped)) {
|
||||||
return if(!upd_writeFile($root, $restoreDir,
|
return if(!upd_writeFile($root, $restoreDir,
|
||||||
"FHEM/$ctrlFileName", $remCtrlFile));
|
"FHEM/$ctrlFileName", $remCtrlFile));
|
||||||
}
|
}
|
||||||
|
|
||||||
return "" if(!$nChanged);
|
|
||||||
|
|
||||||
if($canJoin && $needJoin && $curr == $max) {
|
if($canJoin && $upd_needJoin && $curr == $max) {
|
||||||
chdir($root);
|
chdir($root);
|
||||||
uLog(1, "Calling $^X $cj, this may take a while");
|
uLog(1, "Calling $^X $cj, this may take a while");
|
||||||
my $ret = `$^X $cj`;
|
my $ret = `$^X $cj`;
|
||||||
@ -390,6 +391,8 @@ doUpdate($$$$)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return "" if(!$nChanged);
|
||||||
|
|
||||||
uLog(1, "");
|
uLog(1, "");
|
||||||
if($curr == $max) {
|
if($curr == $max) {
|
||||||
uLog 1,
|
uLog 1,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user