changeset 394:315f31e4f964

fetch_weather: Make purge_threshold option entirely optional, e.g. not set or 0 will disable purging.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 05 Jan 2017 23:14:55 +0200
parents 9a33575eb999
children 33b5e7adc30c
files fetch_weather.pl
diffstat 1 files changed, 14 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- 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};
+      }
+    }
   }
 }