Prevent the use of an invalid unique_id from throwing an exception

during get_torrent_state().
This commit is contained in:
Andrew Resch 2008-01-18 03:40:38 +00:00
commit 8fadfb8254

View file

@ -465,18 +465,20 @@ class Manager:
def get_torrent_state(self, unique_ID): def get_torrent_state(self, unique_ID):
# Check to see if unique_ID exists: # Check to see if unique_ID exists:
if unique_ID not in self.unique_IDs: if unique_ID not in self.unique_IDs:
raise InvalidUniqueIDError(_("Asked for a torrent that doesn't exist")) print "Asked for a torrent that doesn't exist"
return
try:
ret = self.get_core_torrent_state(unique_ID).copy()
ret = self.get_core_torrent_state(unique_ID).copy() # Add the deluge-level things to the deluge_core data
ret.update(self.get_supp_torrent_state(unique_ID))
# Add the deluge-level things to the deluge_core data # Get queue position
ret.update(self.get_supp_torrent_state(unique_ID)) torrent = self.unique_IDs[unique_ID]
ret['queue_pos'] = self.state.queue.index(torrent) + 1
# Get queue position return ret
torrent = self.unique_IDs[unique_ID] except:
ret['queue_pos'] = self.state.queue.index(torrent) + 1 return None
return ret
def get_torrent_peer_info(self, unique_ID): def get_torrent_peer_info(self, unique_ID):
# Perhaps at some time we may add info here # Perhaps at some time we may add info here