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
435ef112fb
commit
c57939baa2
@ -389,9 +389,12 @@ class Core(
|
|||||||
def export_add_torrent_url(self, url, options):
|
def export_add_torrent_url(self, url, options):
|
||||||
log.info("Attempting to add url %s", url)
|
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.
|
# Get the actual filename of the torrent from the url provided.
|
||||||
filename = url.split("/")[-1]
|
filename = url.split("/")[-1]
|
||||||
|
|
||||||
# Get the .torrent file from the url
|
# Get the .torrent file from the url
|
||||||
torrent_file = deluge.common.fetch_url(url)
|
torrent_file = deluge.common.fetch_url(url)
|
||||||
if torrent_file is None:
|
if torrent_file is None:
|
||||||
@ -405,8 +408,7 @@ class Core(
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
# Add the torrent to session
|
# Add the torrent to session
|
||||||
return self.export_add_torrent_file(
|
return callback(filename, filedump, options)
|
||||||
filename, filedump, options)
|
|
||||||
|
|
||||||
def export_add_torrent_magnets(self, uris, options):
|
def export_add_torrent_magnets(self, uris, options):
|
||||||
for uri in uris:
|
for uri in uris:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user