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 zcmV-s1eyDZP)q9XH0)eqMs#-e~P5MPCv)cBAKK;l9KFm%e{kdjx@$W}WsRMM&_g1#z)Lc?xS zBarxGB5gG7A~c?Ui3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