Added a exception catcher to the verify download function to catch corrupt/null torrent file exceptions.

This commit is contained in:
echel0n 2014-12-19 23:40:19 -08:00
parent 2e13186256
commit cac4af0ed7
1 changed files with 12 additions and 9 deletions

View File

@ -188,15 +188,18 @@ class GenericProvider:
# primitive verification of torrents, just make sure we didn't get a text file or something
if self.providerType == GenericProvider.TORRENT:
parser = createParser(file_name)
if parser:
mime_type = parser._getMimeType()
try:
parser.stream._input.close()
except:
pass
if mime_type == 'application/x-bittorrent':
return True
try:
parser = createParser(file_name)
if parser:
mime_type = parser._getMimeType()
try:
parser.stream._input.close()
except:
pass
if mime_type == 'application/x-bittorrent':
return True
except Exception as e:
logger.log(u"Failed to validate torrent file: " + ex(e), logger.DEBUG)
logger.log(u"Result is not a valid torrent file", logger.WARNING)
return False