Move the InvalidTorrentError check to torrentmanager.remove

This commit is contained in:
Andrew Resch 2009-07-24 23:40:03 +00:00
parent 5977647528
commit 321e042a06
2 changed files with 19 additions and 4 deletions

View File

@ -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

View File

@ -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))