Author: andar
Revision: 5093
Log:
Only emit a TorrentStateChangedEvent when the state has actually changed
Diff:
Modified: trunk/deluge/core/torrentmanager.py
===================================================================
--- trunk/deluge/core/torrentmanager.py 2009-04-19 19:50:39 UTC (rev 5092)
+++ trunk/deluge/core/torrentmanager.py 2009-04-19 19:51:11 UTC (rev 5093)
@@ -649,8 +649,10 @@
# Get the torrent_id
torrent_id = str(alert.handle.info_hash())
# Set the torrent state
+ old_state = self.torrents[torrent_id].state
self.torrents[torrent_id].update_state()
-
component.get("EventManager").emit(TorrentStateChangedEvent(torrent_id,
"Paused"))
+ if self.torrents[torrent_id].state != old_state:
+
component.get("EventManager").emit(TorrentStateChangedEvent(torrent_id,
self.torrents[torrent_id].state))
# Write the fastresume file
self.torrents[torrent_id].save_resume_data()
@@ -746,7 +748,11 @@
torrent_id = str(alert.handle.info_hash())
torrent = self.torrents[torrent_id]
torrent.is_finished = torrent.handle.is_seed()
+ old_state = torrent.state
torrent.update_state()
+ if torrent.state != old_state:
+ # We need to emit a TorrentStateChangedEvent too
+
component.get("EventManager").emit(TorrentStateChangedEvent(torrent_id,
torrent.state))
component.get("EventManager").emit(TorrentResumedEvent(torrent_id))
def on_alert_state_changed(self, alert):
@@ -757,8 +763,11 @@
return
if torrent_id in self.torrents:
+ old_state = self.torrents[torrent_id].state
self.torrents[torrent_id].update_state()
-
component.get("EventManager").emit(TorrentStateChangedEvent(torrent_id,
self.torrents[torrent_id].state))
+ # Only emit a state changed event if the state has actually changed
+ if self.torrents[torrent_id].state != old_state:
+
component.get("EventManager").emit(TorrentStateChangedEvent(torrent_id,
self.torrents[torrent_id].state))
def on_alert_save_resume_data(self, alert):
log.debug("on_alert_save_resume_data")
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"deluge-commit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/deluge-commit?hl=en
-~----------~----~----~----~------~----~------~--~---