From 7e51c827052bd23812d7d1897a9a05115650c778 Mon Sep 17 00:00:00 2001 From: Calum Lind Date: Thu, 30 Jun 2011 22:38:07 +0100 Subject: [PATCH] Improved fix for losing Labels upon restart --- deluge/plugins/label/label/core.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/deluge/plugins/label/label/core.py b/deluge/plugins/label/label/core.py index 7b1ea6faf..615d8284e 100644 --- a/deluge/plugins/label/label/core.py +++ b/deluge/plugins/label/label/core.py @@ -97,6 +97,7 @@ class Core(CorePluginBase): log.info("*** Start Label plugin ***") self.plugin = component.get("CorePluginManager") self.plugin.register_status_field("label", self._status_get_label) + self.torrent_manager = component.get("TorrentManager") #__init__ core = component.get("Core") @@ -110,9 +111,7 @@ class Core(CorePluginBase): self.clean_initial_config() - def on_session_started(): - component.get("EventManager").register_event_handler("TorrentAddedEvent", self.post_torrent_add) - component.get("EventManager").register_event_handler("SessionStartedEvent", on_session_started) + component.get("EventManager").register_event_handler("TorrentAddedEvent", self.post_torrent_add) component.get("EventManager").register_event_handler("TorrentRemovedEvent", self.post_torrent_remove) #register tree: @@ -132,6 +131,8 @@ class Core(CorePluginBase): ## Plugin hooks ## def post_torrent_add(self, torrent_id): + if not self.torrent_manager.session_started: + return log.debug("post_torrent_add") torrent = self.torrents[torrent_id]