mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-02 22:48:40 +00:00
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:
parent
5b4d138baf
commit
191d83c4be
2 changed files with 14 additions and 7 deletions
|
@ -84,10 +84,17 @@ class Core(CorePluginBase):
|
||||||
|
|
||||||
self.config = deluge.configmanager.ConfigManager("blocklist.conf", DEFAULT_PREFS)
|
self.config = deluge.configmanager.ConfigManager("blocklist.conf", DEFAULT_PREFS)
|
||||||
if self.config["load_on_start"]:
|
if self.config["load_on_start"]:
|
||||||
# TODO: Check if been more than check_after_days
|
if self.config["last_update"]:
|
||||||
self.use_cache = True
|
now = datetime.datetime.now()
|
||||||
d = self.import_list()
|
last_update = datetime.datetime.strptime(self.config["last_update"],
|
||||||
d.addCallbacks(self.on_import_complete, self.on_import_error)
|
"%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
|
# This function is called every 'check_after_days' days, to download
|
||||||
# and import a new list if needed.
|
# and import a new list if needed.
|
||||||
|
@ -175,10 +182,10 @@ class Core(CorePluginBase):
|
||||||
import socket
|
import socket
|
||||||
socket.setdefaulttimeout(self.config["timeout"])
|
socket.setdefaulttimeout(self.config["timeout"])
|
||||||
|
|
||||||
headers = {}
|
|
||||||
if not url:
|
if not url:
|
||||||
url = self.config["url"]
|
url = self.config["url"]
|
||||||
|
|
||||||
|
headers = {}
|
||||||
if self.config["last_update"] and not self.force_download:
|
if self.config["last_update"] and not self.force_download:
|
||||||
headers['If-Modified-Since'] = self.config["last_update"]
|
headers['If-Modified-Since'] = self.config["last_update"]
|
||||||
|
|
||||||
|
|
|
@ -158,11 +158,11 @@ class GtkUI(GtkPluginBase):
|
||||||
|
|
||||||
def _on_button_check_download_clicked(self, widget):
|
def _on_button_check_download_clicked(self, widget):
|
||||||
self._on_apply_prefs()
|
self._on_apply_prefs()
|
||||||
client.blocklist.import_list(False)
|
client.blocklist.check_import()
|
||||||
|
|
||||||
def _on_button_force_download_clicked(self, widget):
|
def _on_button_force_download_clicked(self, widget):
|
||||||
self._on_apply_prefs()
|
self._on_apply_prefs()
|
||||||
client.blocklist.import_list(True)
|
client.blocklist.check_import(force=True)
|
||||||
|
|
||||||
def _on_status_item_clicked(self, widget, event):
|
def _on_status_item_clicked(self, widget, event):
|
||||||
component.get("Preferences").show("Blocklist")
|
component.get("Preferences").show("Blocklist")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue