mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-09 18:08:39 +00:00
Add rudimentary support for local files
This commit is contained in:
parent
b06f46ea7c
commit
6312ad4a7e
2 changed files with 19 additions and 8 deletions
|
@ -4,6 +4,9 @@
|
||||||
* Implement #457 progress bars for folders
|
* Implement #457 progress bars for folders
|
||||||
* #496: Remove deprecated functions in favour of get_session_status()
|
* #496: Remove deprecated functions in favour of get_session_status()
|
||||||
|
|
||||||
|
==== Blocklist ====
|
||||||
|
* Implement local blocklist support
|
||||||
|
|
||||||
=== Deluge 1.2.0 (In Development) ===
|
=== Deluge 1.2.0 (In Development) ===
|
||||||
==== Core ====
|
==== Core ====
|
||||||
* Implement new RPC protocol DelugeRPC replacing XMLRPC
|
* Implement new RPC protocol DelugeRPC replacing XMLRPC
|
||||||
|
|
|
@ -75,6 +75,7 @@ class Core(CorePluginBase):
|
||||||
def enable(self):
|
def enable(self):
|
||||||
log.debug('Blocklist: Plugin enabled..')
|
log.debug('Blocklist: Plugin enabled..')
|
||||||
|
|
||||||
|
self.is_url = True
|
||||||
self.is_downloading = False
|
self.is_downloading = False
|
||||||
self.is_importing = False
|
self.is_importing = False
|
||||||
self.has_imported = False
|
self.has_imported = False
|
||||||
|
@ -132,13 +133,18 @@ class Core(CorePluginBase):
|
||||||
self.force_download = force
|
self.force_download = force
|
||||||
self.failed_attempts = 0
|
self.failed_attempts = 0
|
||||||
self.auto_detected = False
|
self.auto_detected = False
|
||||||
|
self.up_to_date = False
|
||||||
if force:
|
if force:
|
||||||
self.reader = None
|
self.reader = None
|
||||||
|
self.is_url = self.config["url"].split("://")[0] in ("http", "https")
|
||||||
|
|
||||||
# Start callback chain
|
# Start callback chain
|
||||||
d = self.download_list()
|
if self.is_url:
|
||||||
d.addCallbacks(self.on_download_complete, self.on_download_error)
|
d = self.download_list()
|
||||||
d.addCallback(self.import_list)
|
d.addCallbacks(self.on_download_complete, self.on_download_error)
|
||||||
|
d.addCallback(self.import_list)
|
||||||
|
else:
|
||||||
|
d = self.import_list(self.config["url"])
|
||||||
d.addCallbacks(self.on_import_complete, self.on_import_error)
|
d.addCallbacks(self.on_import_complete, self.on_import_error)
|
||||||
|
|
||||||
return d
|
return d
|
||||||
|
@ -240,7 +246,6 @@ class Core(CorePluginBase):
|
||||||
|
|
||||||
log.debug("Attempting to download blocklist %s", url)
|
log.debug("Attempting to download blocklist %s", url)
|
||||||
log.debug("Sending headers: %s", headers)
|
log.debug("Sending headers: %s", headers)
|
||||||
self.up_to_date = False
|
|
||||||
self.is_downloading = True
|
self.is_downloading = True
|
||||||
return download_file(url, deluge.configmanager.get_config_dir("blocklist.download"), on_retrieve_data, headers)
|
return download_file(url, deluge.configmanager.get_config_dir("blocklist.download"), on_retrieve_data, headers)
|
||||||
|
|
||||||
|
@ -276,7 +281,7 @@ class Core(CorePluginBase):
|
||||||
if "Moved Permanently" in error_msg:
|
if "Moved Permanently" in error_msg:
|
||||||
log.debug("Setting blocklist url to %s", location)
|
log.debug("Setting blocklist url to %s", location)
|
||||||
self.config["url"] = location
|
self.config["url"] = location
|
||||||
d = self.download_list(url=location)
|
d = self.download_list(location)
|
||||||
d.addCallbacks(self.on_download_complete, self.on_download_error)
|
d.addCallbacks(self.on_download_complete, self.on_download_error)
|
||||||
else:
|
else:
|
||||||
if "Not Modified" in error_msg:
|
if "Not Modified" in error_msg:
|
||||||
|
@ -348,11 +353,14 @@ class Core(CorePluginBase):
|
||||||
self.is_importing = False
|
self.is_importing = False
|
||||||
self.has_imported = True
|
self.has_imported = True
|
||||||
log.debug("Blocklist import complete!")
|
log.debug("Blocklist import complete!")
|
||||||
# Move downloaded blocklist to cache
|
|
||||||
cache = deluge.configmanager.get_config_dir("blocklist.cache")
|
cache = deluge.configmanager.get_config_dir("blocklist.cache")
|
||||||
if blocklist != cache:
|
if blocklist != cache:
|
||||||
log.debug("Moving %s to %s", blocklist, cache)
|
if self.is_url:
|
||||||
d = threads.deferToThread(shutil.move, blocklist, cache)
|
log.debug("Moving %s to %s", blocklist, cache)
|
||||||
|
d = threads.deferToThread(shutil.move, blocklist, cache)
|
||||||
|
else:
|
||||||
|
log.debug("Copying %s to %s", blocklist, cache)
|
||||||
|
d = threads.deferToThread(shutil.copy, blocklist, cache)
|
||||||
return d
|
return d
|
||||||
|
|
||||||
def on_import_error(self, f):
|
def on_import_error(self, f):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue