Have the TorrentInfo object raise an exception if unable to open/bdecode

the torrent file
Catch the exception in AddTorrentDialog
This commit is contained in:
Andrew Resch 2008-11-08 06:15:03 +00:00
parent 35671b3f8e
commit d25ad68521
2 changed files with 16 additions and 11 deletions

View File

@ -44,6 +44,7 @@ class TorrentInfo(object):
self.__m_metadata = bencode.bdecode(open(filename, "rb").read())
except Exception, e:
log.warning("Unable to open %s: %s", filename, e)
raise e
self.__m_info_hash = sha(bencode.bencode(self.__m_metadata["info"])).hexdigest()

View File

@ -185,7 +185,11 @@ class AddTorrentDialog(component.Component):
for filename in filenames:
# Get the torrent data from the torrent file
info = deluge.ui.common.TorrentInfo(filename)
try:
info = deluge.ui.common.TorrentInfo(filename)
except Exception, e:
log.debug("Unable to open torrent file: %s", e)
continue
name = "%s (%s)" % (info.name, os.path.split(filename)[-1])
new_row = self.torrent_liststore.append(