diff --git a/deluge/core/torrentmanager.py b/deluge/core/torrentmanager.py index d60d78575..2387741ed 100644 --- a/deluge/core/torrentmanager.py +++ b/deluge/core/torrentmanager.py @@ -571,12 +571,11 @@ class TorrentManager(component.Component): :raises InvalidTorrentError: if the torrent_id is not in the session """ - - if torrent_id not in self.torrents: + try: + torrent_name = self.torrents[torrent_id].get_status(["name"])["name"] + except KeyError: raise InvalidTorrentError("torrent_id not in session") - torrent_name = self.torrents[torrent_id].get_status(["name"])["name"] - # Emit the signal to the clients component.get("EventManager").emit(PreTorrentRemovedEvent(torrent_id))