Update 'save_path' on storage_moved_alert.

This commit is contained in:
Andrew Resch 2008-01-21 22:24:31 +00:00
parent db97daeeeb
commit 1a0718b4ac
3 changed files with 16 additions and 1 deletions

View File

@ -108,6 +108,9 @@ class Torrent:
def set_prioritize_first_last(self, prioritize):
pass
def set_save_path(self, save_path):
self.save_path = save_path
def get_state(self):
"""Returns the state of this torrent for saving to the session state"""
status = self.handle.status()

View File

@ -100,6 +100,8 @@ class TorrentManager(component.Component):
self.alerts.register_handler("tracker_alert", self.on_alert_tracker)
self.alerts.register_handler("tracker_warning_alert",
self.on_alert_tracker_warning)
self.alerts.register_handler("storage_moved_alert",
self.on_alert_storage_moved)
def start(self):
# Try to load the state from file
@ -611,3 +613,13 @@ class TorrentManager(component.Component):
self.torrents[torrent_id].set_tracker_status(tracker_status)
except KeyError:
log.debug("torrent_id doesn't exist.")
def on_alert_storage_moved(self, alert):
log.debug("on_alert_storage_moved")
# Get the torrent_id
torrent_id = str(alert.handle.info_hash())
try:
self.torrents[torrent_id].set_save_path(alert.handle.save_path())
except KeyError:
log.debug("torrent_id doesn't exist.")