Fix #1934 : Unicode error in AddTorrent Dialog

This commit is contained in:
Calum Lind 2011-12-01 18:35:30 +00:00
parent 0941377fac
commit 370035ffc5
1 changed files with 10 additions and 1 deletions

View File

@ -196,7 +196,16 @@ class AddTorrentDialog(component.Component):
for filename in filenames:
# Convert the path to unicode
filename = unicode(filename)
log.debug("Adding torrent from file: %s (%s)", filename, type(filename))
try:
filename = unicode(filename, "utf8")
except UnicodeDecodeError:
# Try 'latin-1' if filename has originated from http
log.debug("Decode with 'utf-8' failed trying 'latin-1'")
filename = unicode(filename, "latin-1")
except TypeError:
# Already unicode
pass
# Get the torrent data from the torrent file
try: