aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--slacktopic.pl17
1 files changed, 15 insertions, 2 deletions
diff --git a/slacktopic.pl b/slacktopic.pl
index 4471584..256db09 100644
--- a/slacktopic.pl
+++ b/slacktopic.pl
@@ -290,7 +290,7 @@ sub finish_update {
}
# Make sure this is a security fix update.
- return unless is_security_update();
+ return unless is_security_update($new_date);
# Ask ChanServ to change the topic for us. We don't need +o in
# the channel, so long as we're logged in to services and have +t.
@@ -325,12 +325,24 @@ sub exec_update {
0); # last arg is unused
}
+# Without %sec_check_cache, every non-security update would result in us
+# wasting bandwidth rechecking the ChangeLog every $update_frequency sec.
+our %sec_check_cache = ();
+
# Return true if the first ChangeLog entry is a security update. Unlike
# the regular check-for-update that happens periodically, this one blocks
# for up to $cmd_timeout seconds. The updates only happen every few days,
# I don't see this as a real problem that needs extra complexity to solve.
sub is_security_update {
- debugmsg("is_security_update() called");
+ my $date = shift;
+ debugmsg("is_security_update($date) called");
+
+ if(exists($sec_check_cache{$date})) {
+ debugmsg("already checked & got '$sec_check_cache{$date}' for $date");
+ return $sec_check_cache{$date};
+ }
+
+ debugmsg("getting start of ChangeLog");
my $result = 0;
my $lines = 0;
@@ -365,6 +377,7 @@ sub is_security_update {
}
debugmsg("read $lines lines from ChangeLog, returning $result");
+ $sec_check_cache{$date} = $result;
return $result;
}