Fix exception when removing torrents.
This commit is contained in:
parent
cc4fc60db0
commit
a17328fff7
|
@ -173,6 +173,11 @@ class TorrentManager:
|
||||||
# The torrent was not added to the session
|
# The torrent was not added to the session
|
||||||
return None
|
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
|
# Set per-torrent limits
|
||||||
handle.set_max_connections(self.max_connections)
|
handle.set_max_connections(self.max_connections)
|
||||||
handle.set_max_uploads(self.max_uploads)
|
handle.set_max_uploads(self.max_uploads)
|
||||||
|
@ -199,10 +204,7 @@ class TorrentManager:
|
||||||
log.warning("Unable to save torrent file: %s", filename)
|
log.warning("Unable to save torrent file: %s", filename)
|
||||||
|
|
||||||
log.debug("Torrent %s added.", handle.info_hash())
|
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
|
# Save the session state
|
||||||
self.save_state()
|
self.save_state()
|
||||||
return torrent.torrent_id
|
return torrent.torrent_id
|
||||||
|
@ -378,14 +380,20 @@ class TorrentManager:
|
||||||
# Get the torrent_id
|
# Get the torrent_id
|
||||||
torrent_id = str(alert.handle.info_hash())
|
torrent_id = str(alert.handle.info_hash())
|
||||||
# Set the tracker status for the torrent
|
# Set the tracker status for the torrent
|
||||||
|
try:
|
||||||
self.torrents[torrent_id].set_tracker_status(_("Announce OK"))
|
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):
|
def on_alert_tracker_announce(self, alert):
|
||||||
log.debug("on_alert_tracker_announce")
|
log.debug("on_alert_tracker_announce")
|
||||||
# Get the torrent_id
|
# Get the torrent_id
|
||||||
torrent_id = str(alert.handle.info_hash())
|
torrent_id = str(alert.handle.info_hash())
|
||||||
# Set the tracker status for the torrent
|
# Set the tracker status for the torrent
|
||||||
|
try:
|
||||||
self.torrents[torrent_id].set_tracker_status(_("Announce Sent"))
|
self.torrents[torrent_id].set_tracker_status(_("Announce Sent"))
|
||||||
|
except KeyError:
|
||||||
|
log.debug("torrent_id doesn't exist.")
|
||||||
|
|
||||||
def on_alert_tracker(self, alert):
|
def on_alert_tracker(self, alert):
|
||||||
log.debug("on_alert_tracker")
|
log.debug("on_alert_tracker")
|
||||||
|
@ -396,7 +404,10 @@ class TorrentManager:
|
||||||
_("HTTP code"), alert.status_code,
|
_("HTTP code"), alert.status_code,
|
||||||
_("times in a row"), alert.times_in_row)
|
_("times in a row"), alert.times_in_row)
|
||||||
# Set the tracker status for the torrent
|
# Set the tracker status for the torrent
|
||||||
|
try:
|
||||||
self.torrents[torrent_id].set_tracker_status(tracker_status)
|
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):
|
def on_alert_tracker_warning(self, alert):
|
||||||
log.debug("on_alert_tracker_warning")
|
log.debug("on_alert_tracker_warning")
|
||||||
|
@ -404,4 +415,7 @@ class TorrentManager:
|
||||||
torrent_id = str(alert.handle.info_hash())
|
torrent_id = str(alert.handle.info_hash())
|
||||||
tracker_status = '%s: %s' % (_("Warning"), str(alert.msg()))
|
tracker_status = '%s: %s' % (_("Warning"), str(alert.msg()))
|
||||||
# Set the tracker status for the torrent
|
# Set the tracker status for the torrent
|
||||||
|
try:
|
||||||
self.torrents[torrent_id].set_tracker_status(tracker_status)
|
self.torrents[torrent_id].set_tracker_status(tracker_status)
|
||||||
|
except KeyError:
|
||||||
|
log.debug("torrent_id doesn't exist.")
|
||||||
|
|
Loading…
Reference in New Issue