mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-08 09:28:41 +00:00
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:
parent
35671b3f8e
commit
d25ad68521
2 changed files with 16 additions and 11 deletions
|
@ -44,6 +44,7 @@ class TorrentInfo(object):
|
||||||
self.__m_metadata = bencode.bdecode(open(filename, "rb").read())
|
self.__m_metadata = bencode.bdecode(open(filename, "rb").read())
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
log.warning("Unable to open %s: %s", filename, e)
|
log.warning("Unable to open %s: %s", filename, e)
|
||||||
|
raise e
|
||||||
|
|
||||||
self.__m_info_hash = sha(bencode.bencode(self.__m_metadata["info"])).hexdigest()
|
self.__m_info_hash = sha(bencode.bencode(self.__m_metadata["info"])).hexdigest()
|
||||||
|
|
||||||
|
|
|
@ -185,7 +185,11 @@ class AddTorrentDialog(component.Component):
|
||||||
|
|
||||||
for filename in filenames:
|
for filename in filenames:
|
||||||
# Get the torrent data from the torrent file
|
# Get the torrent data from the torrent file
|
||||||
|
try:
|
||||||
info = deluge.ui.common.TorrentInfo(filename)
|
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])
|
name = "%s (%s)" % (info.name, os.path.split(filename)[-1])
|
||||||
new_row = self.torrent_liststore.append(
|
new_row = self.torrent_liststore.append(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue