From 813063bd12ddde294c764bfd6641aaeb6379b89b Mon Sep 17 00:00:00 2001 From: John Garland Date: Mon, 19 Jan 2009 06:02:58 +0000 Subject: [PATCH] need_new_blocklist now checks if remote blockist is newer/bigger --- deluge/plugins/blocklist/blocklist/core.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/deluge/plugins/blocklist/blocklist/core.py b/deluge/plugins/blocklist/blocklist/core.py index 031875562..20beded03 100644 --- a/deluge/plugins/blocklist/blocklist/core.py +++ b/deluge/plugins/blocklist/blocklist/core.py @@ -258,7 +258,19 @@ class Core(CorePluginBase): if list_size == 0: return True - if current_time >= (list_time + datetime.timedelta(days=self.config["check_after_days"])): + import socket + socket.setdefaulttimeout(self.config["timeout"]) + + try: + # Get remote blocklist time stamp and size + remote_stats = urllib.urlopen(self.config["url"]).info() + remote_size = remote_stats["content-length"] + remote_time = datetime.datetime.strptime(remote_stats["last-modified"],"%a, %d %b %Y %H:%M:%S GMT") + except Exception, e: + log.debug("Unable to get blocklist stats: %s", e) + return False + + if list_time < remote_time or list_size < remote_size: return True return False