# HG changeset patch # User Matti Hamalainen # Date 1483650895 -7200 # Node ID 315f31e4f9642b740af9d286866c83ee87e2f901 # Parent 9a33575eb999f40006192886296fbcfa47efa5d1 fetch_weather: Make purge_threshold option entirely optional, e.g. not set or 0 will disable purging. diff -r 9a33575eb999 -r 315f31e4f964 fetch_weather.pl --- a/fetch_weather.pl Wed Dec 21 20:46:14 2016 +0200 +++ b/fetch_weather.pl Thu Jan 05 23:14:55 2017 +0200 @@ -529,17 +529,22 @@ ### -### Purge very old entries, default to 60 minutes +### Purge too old entries ### -my $wqtime = time(); -my $purge = opt_get_int("purge_threshold"); -$purge = 60 if ($purge <= 0); +if (opt_chk_valid("purge_threshold", 1)) +{ + my $purge = opt_get_int("purge_threshold"); + if ($purge > 0) + { + my $wqtime = time(); -foreach my $key (keys %$weatherdata) -{ - if ($wqtime - $weatherdata->{$key}[1] > (60 * $purge)) - { - delete $$weatherdata{$key}; + foreach my $key (keys %$weatherdata) + { + if ($wqtime - $weatherdata->{$key}[1] > (60 * $purge)) + { + delete $$weatherdata{$key}; + } + } } }