diff options
author | deaddrop9 <dead.drop.9@digitalfootlocker.au> | 2022-03-28 19:12:54 +1100 |
---|---|---|
committer | Calum Lind <calumlind+deluge@gmail.com> | 2022-05-01 18:34:19 +0100 |
commit | bc6611fc0dd1b51dc1e9b816c985c1f71f002798 (patch) | |
tree | 3080c88fd1151600879f50bf6688325dba6f1b51 /deluge | |
parent | 970a0ae2409d57eb3aa00b621ad4474fbb27b4de (diff) | |
download | deluge-bc6611fc0dd1b51dc1e9b816c985c1f71f002798.tar.gz deluge-bc6611fc0dd1b51dc1e9b816c985c1f71f002798.tar.bz2 deluge-bc6611fc0dd1b51dc1e9b816c985c1f71f002798.zip |
[AutoAdd] Verify torrent decode and errors cleanly if invalid
Watch folder was disabled in AutoAdd and torrent filename is unchanged
if an invalid torrent was added.
Trac: https://dev.deluge-torrent.org/ticket/3515
Closes: https://github.com/deluge-torrent/deluge/pull/381
Diffstat (limited to 'deluge')
-rw-r--r-- | deluge/plugins/AutoAdd/deluge_autoadd/core.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/deluge/plugins/AutoAdd/deluge_autoadd/core.py b/deluge/plugins/AutoAdd/deluge_autoadd/core.py index ed6a0323b..07ad53a8e 100644 --- a/deluge/plugins/AutoAdd/deluge_autoadd/core.py +++ b/deluge/plugins/AutoAdd/deluge_autoadd/core.py @@ -27,7 +27,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.error import AddTorrentError, InvalidTorrentError from deluge.event import DelugeEvent from deluge.plugins.pluginbase import CorePluginBase @@ -158,7 +158,10 @@ class Core(CorePluginBase): # Get the info to see if any exceptions are raised if not magnet: - lt.torrent_info(lt.bdecode(filedump)) + decoded_torrent = lt.bdecode(filedump) + if decoded_torrent is None: + raise InvalidTorrentError('Torrent file failed decoding.') + lt.torrent_info(decoded_torrent) return filedump @@ -268,7 +271,7 @@ class Core(CorePluginBase): try: filedump = self.load_torrent(filepath, magnet) - except (OSError, EOFError) as ex: + except (OSError, EOFError, InvalidTorrentError) as ex: # If torrent is invalid, keep track of it so can try again on the next pass. # This catches torrent files that may not be fully saved to disk at load time. log.debug('Torrent is invalid: %s', ex) |