mirror of
https://github.com/codex-storage/deluge.git
synced 2025-02-17 13:56:47 +00:00
Blocklist updates
This commit is contained in:
parent
31a4c4159f
commit
64e8a34940
@ -77,6 +77,12 @@ class Core(CorePluginBase):
|
|||||||
if self.config["load_on_start"]:
|
if self.config["load_on_start"]:
|
||||||
self.export_import(self.need_new_blocklist())
|
self.export_import(self.need_new_blocklist())
|
||||||
|
|
||||||
|
# This function is called every 'check_after_days' days, to download
|
||||||
|
# and import a new list if needed.
|
||||||
|
self.update_timer = gobject.timeout_add(
|
||||||
|
self.config["check_after_days"] * 24 * 60 * 60 * 1000,
|
||||||
|
self.download_blocklist, True)
|
||||||
|
|
||||||
def disable(self):
|
def disable(self):
|
||||||
log.debug('Blocklist: Plugin disabled')
|
log.debug('Blocklist: Plugin disabled')
|
||||||
self.config.save()
|
self.config.save()
|
||||||
@ -207,11 +213,12 @@ class Core(CorePluginBase):
|
|||||||
"""Returns True if a new blocklist file should be downloaded"""
|
"""Returns True if a new blocklist file should be downloaded"""
|
||||||
try:
|
try:
|
||||||
# Check current block lists time stamp and decide if it needs to be replaced
|
# Check current block lists time stamp and decide if it needs to be replaced
|
||||||
list_stats = os.stat(self.local_blocklist)
|
list_stats = os.stat(deluge.configmanager.get_config_dir("blocklist.cache"))
|
||||||
list_time = datetime.datetime.fromtimestamp(list_stats.st_mtime)
|
list_time = datetime.datetime.fromtimestamp(list_stats.st_mtime)
|
||||||
list_size = list_stats.st_size
|
list_size = list_stats.st_size
|
||||||
current_time = datetime.datetime.today()
|
current_time = datetime.datetime.today()
|
||||||
except:
|
except Exception, e:
|
||||||
|
log.debug("Unable to get file stats: %s", e)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
# If local blocklist file exists but nothing is in it
|
# If local blocklist file exists but nothing is in it
|
||||||
|
@ -48,7 +48,7 @@ class GtkUI(ui.UI):
|
|||||||
|
|
||||||
self.status_item = component.get("StatusBar").add_item(
|
self.status_item = component.get("StatusBar").add_item(
|
||||||
image=self.get_resource("blocklist16.png"),
|
image=self.get_resource("blocklist16.png"),
|
||||||
text="0",
|
text="",
|
||||||
callback=self._on_status_item_clicked,
|
callback=self._on_status_item_clicked,
|
||||||
tooltip="Blocked IP Ranges")
|
tooltip="Blocked IP Ranges")
|
||||||
|
|
||||||
@ -62,6 +62,10 @@ class GtkUI(ui.UI):
|
|||||||
# Remove the preferences page
|
# Remove the preferences page
|
||||||
self.plugin.remove_preferences_page("Blocklist")
|
self.plugin.remove_preferences_page("Blocklist")
|
||||||
|
|
||||||
|
# Remove status item
|
||||||
|
component.get("StatusBar").remove_item(self.status_item)
|
||||||
|
del self.status_item
|
||||||
|
|
||||||
# Deregister the hooks
|
# Deregister the hooks
|
||||||
self.plugin.deregister_hook("on_apply_prefs", self._on_apply_prefs)
|
self.plugin.deregister_hook("on_apply_prefs", self._on_apply_prefs)
|
||||||
self.plugin.deregister_hook("on_show_prefs", self._on_show_prefs)
|
self.plugin.deregister_hook("on_show_prefs", self._on_show_prefs)
|
||||||
|
@ -42,6 +42,9 @@ class PluginBase:
|
|||||||
self.plugin.enable()
|
self.plugin.enable()
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
log.warning("Unable to enable plugin: %s", e)
|
log.warning("Unable to enable plugin: %s", e)
|
||||||
|
else:
|
||||||
|
# If plugin was enabled, call it's update() right away
|
||||||
|
self.update()
|
||||||
|
|
||||||
def disable(self):
|
def disable(self):
|
||||||
try:
|
try:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user