diff --git a/deluge/plugins/blocklist/blocklist/core.py b/deluge/plugins/blocklist/blocklist/core.py index 884ed3e13..24d3c31f5 100644 --- a/deluge/plugins/blocklist/blocklist/core.py +++ b/deluge/plugins/blocklist/blocklist/core.py @@ -84,10 +84,17 @@ class Core(CorePluginBase): self.config = deluge.configmanager.ConfigManager("blocklist.conf", DEFAULT_PREFS) if self.config["load_on_start"]: - # TODO: Check if been more than check_after_days - self.use_cache = True - d = self.import_list() - d.addCallbacks(self.on_import_complete, self.on_import_error) + if self.config["last_update"]: + now = datetime.datetime.now() + last_update = datetime.datetime.strptime(self.config["last_update"], + "%a, %d %b %Y %H:%M:%S GMT") + check_period = datetime.timedelta(days=self.config["check_after_days"]) + if not self.config["last_update"] or last_update + check_period >= now: + d = self.check_import() + else: + self.use_cache = True + d = self.import_list() + d.addCallbacks(self.on_import_complete, self.on_import_error) # This function is called every 'check_after_days' days, to download # and import a new list if needed. @@ -175,10 +182,10 @@ class Core(CorePluginBase): import socket socket.setdefaulttimeout(self.config["timeout"]) - headers = {} if not url: url = self.config["url"] + headers = {} if self.config["last_update"] and not self.force_download: headers['If-Modified-Since'] = self.config["last_update"] diff --git a/deluge/plugins/blocklist/blocklist/gtkui.py b/deluge/plugins/blocklist/blocklist/gtkui.py index dd3b7b261..17bae84dd 100644 --- a/deluge/plugins/blocklist/blocklist/gtkui.py +++ b/deluge/plugins/blocklist/blocklist/gtkui.py @@ -158,11 +158,11 @@ class GtkUI(GtkPluginBase): def _on_button_check_download_clicked(self, widget): self._on_apply_prefs() - client.blocklist.import_list(False) + client.blocklist.check_import() def _on_button_force_download_clicked(self, widget): self._on_apply_prefs() - client.blocklist.import_list(True) + client.blocklist.check_import(force=True) def _on_status_item_clicked(self, widget, event): component.get("Preferences").show("Blocklist")