From 321e042a0631d274117fc1af38fd0bf5c2a8b131 Mon Sep 17 00:00:00 2001 From: Andrew Resch Date: Fri, 24 Jul 2009 23:40:03 +0000 Subject: [PATCH] Move the InvalidTorrentError check to torrentmanager.remove --- deluge/core/core.py | 3 --- deluge/core/torrentmanager.py | 20 +++++++++++++++++++- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/deluge/core/core.py b/deluge/core/core.py index 693aa7e05..2a135efdf 100644 --- a/deluge/core/core.py +++ b/deluge/core/core.py @@ -335,9 +335,6 @@ class Core(component.Component): """ log.debug("Removing torrent %s from the core.", torrent_id) - if torrent_id not in self.torrentmanager.torrents: - raise InvalidTorrentError("torrent_id not in session") - return self.torrentmanager.remove(torrent_id, remove_data) @export diff --git a/deluge/core/torrentmanager.py b/deluge/core/torrentmanager.py index b538d0114..f31c1fd7a 100644 --- a/deluge/core/torrentmanager.py +++ b/deluge/core/torrentmanager.py @@ -54,6 +54,7 @@ except ImportError: from deluge.event import * +from deluge.error import * import deluge.common import deluge.component as component from deluge.configmanager import ConfigManager @@ -462,7 +463,24 @@ class TorrentManager(component.Component): return filedump def remove(self, torrent_id, remove_data=False): - """Remove a torrent from the manager""" + """ + Remove a torrent from the session. + + :param torrent_id: the torrent to remove + :type torrent_id: string + :param remove_data: if True, remove the downloaded data + :type remove_data: bool + + :returns: True if removed successfully, False if not + :rtype: bool + + :raises InvalidTorrentError: if the torrent_id is not in the session + + """ + + if torrent_id not in self.torrents: + raise InvalidTorrentError("torrent_id not in session") + # Emit the signal to the clients component.get("EventManager").emit(PreTorrentRemovedEvent(torrent_id))