From 96687a996b589baac1607e476b5760338fb3c126 Mon Sep 17 00:00:00 2001 From: Andrew Resch Date: Tue, 12 May 2009 20:22:21 +0000 Subject: [PATCH] Fix #934 use 'name.utf-8' if available and decode the file path before joining it with the prefix --- deluge/ui/common.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/deluge/ui/common.py b/deluge/ui/common.py index ebd5d9460..fbc75f3d0 100644 --- a/deluge/ui/common.py +++ b/deluge/ui/common.py @@ -84,7 +84,12 @@ class TorrentInfo(object): elif "codepage" in self.__m_metadata: self.encoding = str(self.__m_metadata["codepage"]) - self.__m_name = decode_string(self.__m_metadata["info"]["name"]) + # Check if 'name.utf-8' is in the torrent and if not try to decode the string + # using the encoding found. + if "name.utf-8" in self.__m_metadata["info"]: + self.__m_name = decode_string(self.__m_metadata["info"]["name.utf-8"]) + else: + self.__m_name = decode_string(self.__m_metadata["info"]["name"], self.encoding) # Get list of files from torrent info self.__m_files = [] @@ -95,7 +100,7 @@ class TorrentInfo(object): for f in self.__m_metadata["info"]["files"]: self.__m_files.append({ - 'path': decode_string(os.path.join(prefix, *f["path"])), + 'path': decode_string(os.path.join(prefix, decode_string(os.path.join(*f["path"])))) 'size': f["length"], 'download': True })