diff --git a/ChangeLog b/ChangeLog index f8d282346..8571745ef 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 diff --git a/deluge/core/core.py b/deluge/core/core.py index 8c4587e2b..528c97f1e 100644 --- a/deluge/core/core.py +++ b/deluge/core/core.py @@ -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) diff --git a/deluge/ui/webui/torrent_add.py b/deluge/ui/webui/torrent_add.py index 13dbd5099..523fa5956 100644 --- a/deluge/ui/webui/torrent_add.py +++ b/deluge/ui/webui/torrent_add.py @@ -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) \ No newline at end of file + component.get("PageManager").register_page("/torrent/add(.*)",torrent_add)