From 42dce915df1eb196736dd4f0f27c5282e151814a Mon Sep 17 00:00:00 2001 From: Andrew Resch Date: Thu, 26 Mar 2009 21:23:56 +0000 Subject: [PATCH] Add PreTorrentRemovedEvent event --- deluge/core/torrentmanager.py | 3 +++ deluge/event.py | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/deluge/core/torrentmanager.py b/deluge/core/torrentmanager.py index 16f2ad1ac..5f9c19db7 100644 --- a/deluge/core/torrentmanager.py +++ b/deluge/core/torrentmanager.py @@ -430,6 +430,9 @@ class TorrentManager(component.Component): def remove(self, torrent_id, remove_data=False): """Remove a torrent from the manager""" + # Emit the signal to the clients + component.get("EventManager").emit(PreTorrentRemovedEvent(torrent_id)) + try: self.session.remove_torrent(self.torrents[torrent_id].handle, 1 if remove_data else 0) diff --git a/deluge/event.py b/deluge/event.py index 5ac814f59..bf98adae7 100644 --- a/deluge/event.py +++ b/deluge/event.py @@ -69,6 +69,16 @@ class TorrentRemovedEvent(DelugeEvent): """ self._args = [torrent_id] +class PreTorrentRemovedEvent(DelugeEvent): + """ + Emitted when a torrent is about to be removed from the session. + """ + def __init__(self, torrent_id): + """ + :param torrent_id: str, the torrent_id + """ + self._args = [torrent_id] + class TorrentStateChangedEvent(DelugeEvent): """ Emitted when a torrent changes state.