From 9aed7a7f0c0fad818f55cc94ed3a706a199b6eb6 Mon Sep 17 00:00:00 2001 From: Calum Lind Date: Tue, 21 Mar 2017 20:21:28 +0000 Subject: [PATCH] [AutoAdd] Handle AddTorrentError exceptions --- .../AutoAdd/deluge/plugins/autoadd/core.py | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/deluge/plugins/AutoAdd/deluge/plugins/autoadd/core.py b/deluge/plugins/AutoAdd/deluge/plugins/autoadd/core.py index b495d43d1..fba1038db 100644 --- a/deluge/plugins/AutoAdd/deluge/plugins/autoadd/core.py +++ b/deluge/plugins/AutoAdd/deluge/plugins/autoadd/core.py @@ -28,6 +28,7 @@ import deluge.configmanager from deluge._libtorrent import lt from deluge.common import AUTH_LEVEL_ADMIN, is_magnet from deluge.core.rpcserver import export +from deluge.error import AddTorrentError from deluge.event import DelugeEvent from deluge.plugins.pluginbase import CorePluginBase @@ -277,13 +278,18 @@ class Core(CorePluginBase): self.invalid_torrents[filename] = 1 continue - # The torrent looks good, so lets add it to the session. - if magnet: - torrent_id = component.get('Core').add_torrent_magnet( - filedump.strip(), options) - else: - torrent_id = component.get('Core').add_torrent_file( - filename, base64.encodestring(filedump), options) + try: + # The torrent looks good, so lets add it to the session. + if magnet: + torrent_id = component.get('Core').add_torrent_magnet( + filedump.strip(), options) + else: + torrent_id = component.get('Core').add_torrent_file( + filename, base64.encodestring(filedump), options) + except AddTorrentError as ex: + log.error(ex) + os.rename(filepath, filepath + '.invalid') + continue # If the torrent added successfully, set the extra options. if torrent_id: