From 5374d237a774abb2a34756c1ce7cec3611c3081d Mon Sep 17 00:00:00 2001 From: Calum Lind Date: Sat, 24 Jul 2021 10:14:47 +0100 Subject: [PATCH] [AutoAdd|3295] Correctly fix auto-adding magnets Properly fix adding magnets, first attempted in previous commit 2e466101fc20a add_torrent_magnet does not return a deferred so wrap in maybeDeferred. Fixed broken test due to new deluge website icon --- deluge/plugins/AutoAdd/deluge_autoadd/core.py | 11 +++++++++-- deluge/tests/data/deluge.png | Bin 722 -> 1126 bytes 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/deluge/plugins/AutoAdd/deluge_autoadd/core.py b/deluge/plugins/AutoAdd/deluge_autoadd/core.py index 668f461f8..9a2260610 100644 --- a/deluge/plugins/AutoAdd/deluge_autoadd/core.py +++ b/deluge/plugins/AutoAdd/deluge_autoadd/core.py @@ -21,7 +21,9 @@ import shutil from base64 import b64encode from twisted.internet import reactor +from twisted.internet.defer import maybeDeferred from twisted.internet.task import LoopingCall, deferLater +from twisted.python.failure import Failure import deluge.component as component import deluge.configmanager @@ -325,6 +327,9 @@ class Core(CorePluginBase): os.remove(filepath) def fail_torrent_add(err_msg, filepath, magnet): + if isinstance(err_msg, Failure): + err_msg = err_msg.getErrorMessage() + # torrent handle is invalid and so is the magnet link log.error( 'Cannot Autoadd %s: %s: %s', @@ -337,8 +342,10 @@ class Core(CorePluginBase): try: # The torrent looks good, so lets add it to the session. if magnet: - d = component.get('Core').add_torrent_magnet( - filedump.strip(), options + d = maybeDeferred( + component.get('Core').add_torrent_magnet, + filedump.strip(), + options, ) else: d = component.get('Core').add_torrent_file_async( diff --git a/deluge/tests/data/deluge.png b/deluge/tests/data/deluge.png index e39cd0c7eebdf68688339b82aebdeecfe9f5fc9c..6787fa39a7a5ced846dc6c11174ea312923c396e 100644 GIT binary patch literal 1126 zcmeAS@N?(olHy`uVBq!ia0y~yU{C;I4mJh`hT^KKFANMUx}GkMAr*{C3s?$v`S3h0 znJaSAK!D*wwW)*WG?s&=$0KfU+k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