Added check to see if blocklist should be downloaded when load on start is enabled.

Updated function names in gtkui.
This commit is contained in:
John Garland 2009-07-04 17:05:50 +00:00
parent 5b4d138baf
commit 191d83c4be
2 changed files with 14 additions and 7 deletions

View File

@ -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"]

View File

@ -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")