57_Calendar: one more code line hardened against non-existent start or end times; evaluate error message returned from HttpUtils

git-svn-id: svn://svn.code.sf.net/p/fhem/code/trunk@6661 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
borisneubert
2014-10-03 07:27:27 +00:00
parent ddeaa611f2
commit 8f7f2f72e6

View File

@@ -639,7 +639,9 @@ sub isEnded {
sub nextTime { sub nextTime {
my ($self,$t) = @_; my ($self,$t) = @_;
my @times= ( $self->{start}, $self->{end} ); my @times= ( );
push @times, $self->{start} if(defined($self->{start}));
push @times, $self->{end} if(defined($self->{end}));
unshift @times, $self->{alarm} if($self->{alarm}); unshift @times, $self->{alarm} if($self->{alarm});
@times= sort grep { $_ > $t } @times; @times= sort grep { $_ > $t } @times;
@@ -880,11 +882,12 @@ sub Calendar_GetUpdate($$) {
my $type = $hash->{fhem}{type}; my $type = $hash->{fhem}{type};
my $url= $hash->{fhem}{url}; my $url= $hash->{fhem}{url};
my $errmsg= "";
my $ics; my $ics;
if($type eq "url"){ if($type eq "url"){
#$ics= GetFileFromURLQuiet($url,10,undef,0,5) if($type eq "url"); #$ics= GetFileFromURLQuiet($url,10,undef,0,5) if($type eq "url");
$ics= HttpUtils_BlockingGet( { url => $url, hideurl => 1, timeout => 10, } ); ($errmsg, $ics)= HttpUtils_BlockingGet( { url => $url, hideurl => 1, timeout => 10, } );
} elsif($type eq "file") { } elsif($type eq "file") {
if(open(ICSFILE, $url)) { if(open(ICSFILE, $url)) {
while(<ICSFILE>) { while(<ICSFILE>) {
@@ -901,8 +904,8 @@ sub Calendar_GetUpdate($$) {
} }
if(!defined($ics) or ("$ics" eq "")) { if(!defined($ics) or ("$ics" eq "") or ($errmsg ne "")) {
Log3 $hash, 1, "Calendar " . $hash->{NAME} . ": Could not retrieve file at URL"; Log3 $hash, 1, "Calendar " . $hash->{NAME} . ": Could not retrieve file at URL. $errmsg";
return 0; return 0;
} }