mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-04 15:38:43 +00:00
A few fixes for the blocklist plugin
This commit is contained in:
parent
c3193f3c70
commit
5c481c3b13
2 changed files with 10 additions and 4 deletions
|
@ -185,6 +185,7 @@ class Core(CorePluginBase):
|
||||||
:param blocklist: path of blocklist
|
:param blocklist: path of blocklist
|
||||||
:type blocklist: string
|
:type blocklist: string
|
||||||
"""
|
"""
|
||||||
|
log.debug("Updating blocklist info: %s", blocklist)
|
||||||
self.config["last_update"] = datetime.datetime.utcnow().strftime("%a, %d %b %Y %H:%M:%S GMT")
|
self.config["last_update"] = datetime.datetime.utcnow().strftime("%a, %d %b %Y %H:%M:%S GMT")
|
||||||
self.config["list_size"] = os.path.getsize(blocklist)
|
self.config["list_size"] = os.path.getsize(blocklist)
|
||||||
|
|
||||||
|
@ -225,7 +226,7 @@ class Core(CorePluginBase):
|
||||||
|
|
||||||
def on_download_complete(self, result):
|
def on_download_complete(self, result):
|
||||||
"""Runs any download clean up functions"""
|
"""Runs any download clean up functions"""
|
||||||
log.debug("Blocklist download complete!")
|
log.debug("Blocklist download complete: %s", result)
|
||||||
self.is_downloading = False
|
self.is_downloading = False
|
||||||
return threads.deferToThread(self.update_info, result)
|
return threads.deferToThread(self.update_info, result)
|
||||||
|
|
||||||
|
@ -247,9 +248,11 @@ class Core(CorePluginBase):
|
||||||
if "Not Modified" in error_msg:
|
if "Not Modified" in error_msg:
|
||||||
log.debug("Blocklist is up-to-date!")
|
log.debug("Blocklist is up-to-date!")
|
||||||
self.up_to_date = True
|
self.up_to_date = True
|
||||||
|
if os.path.exists(deluge.configmanager.get_config_dir("blocklist.cache")):
|
||||||
self.use_cache = True
|
self.use_cache = True
|
||||||
|
bl_filename = "blocklist.cache" if self.use_cache else "blocklist.download"
|
||||||
d = threads.deferToThread(self.update_info,
|
d = threads.deferToThread(self.update_info,
|
||||||
deluge.configmanager.get_config_dir("blocklist.cache"))
|
deluge.configmanager.get_config_dir(bl_filename))
|
||||||
f.trap(f.type)
|
f.trap(f.type)
|
||||||
elif self.failed_attempts < self.config["try_times"]:
|
elif self.failed_attempts < self.config["try_times"]:
|
||||||
log.warning("Blocklist download failed!")
|
log.warning("Blocklist download failed!")
|
||||||
|
|
|
@ -74,5 +74,8 @@ def detect_format(filename, compression=""):
|
||||||
def create_reader(format, compression=""):
|
def create_reader(format, compression=""):
|
||||||
reader = READERS.get(format)
|
reader = READERS.get(format)
|
||||||
if reader and compression:
|
if reader and compression:
|
||||||
reader = DECOMPRESSERS.get(compression)(reader)
|
decompressor = DECOMPRESSERS.get(compression)
|
||||||
|
if decompressor:
|
||||||
|
reader = decompressor(reader)
|
||||||
|
|
||||||
return reader
|
return reader
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue