Create recent alert file if not exists.
die()'ing here didn't make much sense. If the file isn't there, we don't have any recent alerts, so an empty file and returning and empty hash fine. Note this doesn't test if the directory is empty.
This commit is contained in:
parent
0d4f6aae9e
commit
8b78e44bc4
1 changed files with 6 additions and 1 deletions
|
@ -35,7 +35,12 @@ sub ReadRecentWeatherAlerts ($) {
|
|||
|
||||
my %info;
|
||||
my $file = File::Spec->catfile($dir, 'conky-weather-alert-recent');
|
||||
open(RECENT_ALERTS, "<", $file) or die "unable to open $file for reading: $!";
|
||||
unless (open(RECENT_ALERTS, "<", $file)) {
|
||||
# If the file doesn't exist, create it empty.
|
||||
warn "unable to open $file for reading: $! (will recreate)";
|
||||
WriteRecentWeatherAlerts($dir, {});
|
||||
return {};
|
||||
}
|
||||
my $key;
|
||||
my $data = "";
|
||||
foreach my $line (<RECENT_ALERTS>) {
|
||||
|
|
Loading…
Add table
Reference in a new issue