Fix exception when removing torrents.

This commit is contained in:
Andrew Resch 2007-10-02 03:06:40 +00:00
parent cc4fc60db0
commit a17328fff7
1 changed files with 23 additions and 9 deletions

View File

@ -173,6 +173,11 @@ class TorrentManager:
# The torrent was not added to the session
return None
# Create a Torrent object
torrent = Torrent(filename, handle, compact)
# Add the torrent object to the dictionary
self.torrents[torrent.torrent_id] = torrent
# Set per-torrent limits
handle.set_max_connections(self.max_connections)
handle.set_max_uploads(self.max_uploads)
@ -199,10 +204,7 @@ class TorrentManager:
log.warning("Unable to save torrent file: %s", filename)
log.debug("Torrent %s added.", handle.info_hash())
# Create a Torrent object
torrent = Torrent(filename, handle, compact)
# Add the torrent object to the dictionary
self.torrents[torrent.torrent_id] = torrent
# Save the session state
self.save_state()
return torrent.torrent_id
@ -378,14 +380,20 @@ class TorrentManager:
# Get the torrent_id
torrent_id = str(alert.handle.info_hash())
# Set the tracker status for the torrent
try:
self.torrents[torrent_id].set_tracker_status(_("Announce OK"))
except KeyError:
log.debug("torrent_id doesn't exist.")
def on_alert_tracker_announce(self, alert):
log.debug("on_alert_tracker_announce")
# Get the torrent_id
torrent_id = str(alert.handle.info_hash())
# Set the tracker status for the torrent
try:
self.torrents[torrent_id].set_tracker_status(_("Announce Sent"))
except KeyError:
log.debug("torrent_id doesn't exist.")
def on_alert_tracker(self, alert):
log.debug("on_alert_tracker")
@ -396,7 +404,10 @@ class TorrentManager:
_("HTTP code"), alert.status_code,
_("times in a row"), alert.times_in_row)
# Set the tracker status for the torrent
try:
self.torrents[torrent_id].set_tracker_status(tracker_status)
except KeyError:
log.debug("torrent_id doesn't exist.")
def on_alert_tracker_warning(self, alert):
log.debug("on_alert_tracker_warning")
@ -404,4 +415,7 @@ class TorrentManager:
torrent_id = str(alert.handle.info_hash())
tracker_status = '%s: %s' % (_("Warning"), str(alert.msg()))
# Set the tracker status for the torrent
try:
self.torrents[torrent_id].set_tracker_status(tracker_status)
except KeyError:
log.debug("torrent_id doesn't exist.")