mirror of
https://git.deluge-torrent.org/deluge
synced 2025-04-20 11:35:49 +00:00
Fix add_torrent_url() to download the torrent file in a thread to
prevent the main thread from blocking and causing the daemon to freeze.
This commit is contained in:
parent
c2427ccb7d
commit
56b806ce78
3 changed files with 12 additions and 8 deletions
|
@ -3,6 +3,8 @@ Deluge 1.0.1 (In Development)
|
|||
* Change the default max global upload slots to 4 instead of -1 since libtorrent
|
||||
will automatically open more slots to meet the upload speed limit.
|
||||
* Fix display of tracker error messages
|
||||
* Fix add_torrent_url() to download the torrent file in a thread to prevent
|
||||
the main thread from blocking and causing the daemon to freeze.
|
||||
|
||||
GtkUI:
|
||||
* Improve performance of files tab by only updating when values change
|
||||
|
|
|
@ -396,9 +396,12 @@ class Core(
|
|||
# Run the plugin hooks for 'post_torrent_add'
|
||||
self.plugins.run_post_torrent_add(torrent_id)
|
||||
|
||||
def export_add_torrent_url(self, url, save_path, options):
|
||||
def export_add_torrent_url(self, url, options):
|
||||
log.info("Attempting to add url %s", url)
|
||||
|
||||
|
||||
threading.Thread(target=self.fetch_torrent_url_thread, args=(self.export_add_torrent_file, url, options)).start()
|
||||
|
||||
def fetch_torrent_url_thread(self, callback, url, options):
|
||||
# Get the actual filename of the torrent from the url provided.
|
||||
filename = url.split("/")[-1]
|
||||
|
||||
|
@ -406,17 +409,16 @@ class Core(
|
|||
torrent_file = deluge.common.fetch_url(url)
|
||||
if torrent_file is None:
|
||||
return False
|
||||
|
||||
|
||||
# Dump the torrents file contents to a string
|
||||
try:
|
||||
filedump = open(torrent_file, "rb").read()
|
||||
except IOError:
|
||||
log.warning("Unable to open %s for reading.", torrent_file)
|
||||
return False
|
||||
|
||||
|
||||
# Add the torrent to session
|
||||
return self.export_add_torrent_file(
|
||||
filename, filedump, options)
|
||||
return callback(filename, filedump, options)
|
||||
|
||||
def export_remove_torrent(self, torrent_ids, remove_torrent, remove_data):
|
||||
log.debug("Removing torrent %s from the core.", torrent_ids)
|
||||
|
|
|
@ -119,7 +119,7 @@ class torrent_add:
|
|||
return
|
||||
|
||||
if vars.url:
|
||||
proxy.add_torrent_url(vars.url, None,options)
|
||||
proxy.add_torrent_url(vars.url, options)
|
||||
log.debug("add-url:options :%s" % options)
|
||||
self.redirect(vars.choose_files)
|
||||
elif torrent_name:
|
||||
|
@ -140,4 +140,4 @@ class torrent_add:
|
|||
|
||||
|
||||
def register():
|
||||
component.get("PageManager").register_page("/torrent/add(.*)",torrent_add)
|
||||
component.get("PageManager").register_page("/torrent/add(.*)",torrent_add)
|
||||
|
|
Loading…
Add table
Reference in a new issue