Prevent wrongly encoded torrents from causing an xmlrpc exception thus causing

a blank torrent list
This commit is contained in:
Andrew Resch 2008-11-17 08:28:32 +00:00
parent c4e4647f4b
commit c429d56170
1 changed files with 6 additions and 2 deletions

View File

@ -445,7 +445,7 @@ class Torrent:
for index, file in enumerate(files): for index, file in enumerate(files):
ret.append({ ret.append({
'index': index, 'index': index,
'path': file.path, 'path': file.path.decode("utf8", "ignore"),
'size': file.size, 'size': file.size,
'offset': file.offset 'offset': file.offset
}) })
@ -586,7 +586,11 @@ class Torrent:
def ti_name(): def ti_name():
if self.handle.has_metadata(): if self.handle.has_metadata():
return self.torrent_info.name() try:
return self.torrent_info.name().decode("utf8", "ignore")
except UnicodeDecodeError:
return self.torrent_info.name()
return self.torrent_id return self.torrent_id
def ti_priv(): def ti_priv():
if self.handle.has_metadata(): if self.handle.has_metadata():