Author: andar

Revision: 5265

Log:
        Fix #934 use 'name.utf-8' if available and decode the file path before 
joining it with the prefix

Diff:
Modified: branches/1.1.0_RC/deluge/ui/common.py
===================================================================
--- branches/1.1.0_RC/deluge/ui/common.py       2009-05-12 18:10:52 UTC (rev 
5264)
+++ branches/1.1.0_RC/deluge/ui/common.py       2009-05-12 20:22:21 UTC (rev 
5265)
@@ -84,7 +84,12 @@
         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 @@
 
             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
                 })

Modified: trunk/deluge/ui/common.py
===================================================================
--- trunk/deluge/ui/common.py   2009-05-12 18:10:52 UTC (rev 5264)
+++ trunk/deluge/ui/common.py   2009-05-12 20:22:21 UTC (rev 5265)
@@ -76,9 +76,12 @@
         elif "codepage" in self.__m_metadata:
             self.encoding = str(self.__m_metadata["codepage"])
 
-        # We try to decode based on the encoding found and if we can't, we try
-        # to detect the encoding and decode that
-        self.__m_name = decode_string(self.__m_metadata["info"]["name"], 
self.encoding)
+        # 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
         paths = {}
@@ -88,7 +91,7 @@
                 prefix = self.__m_name
 
             for index, f in enumerate(self.__m_metadata["info"]["files"]):
-                path = decode_string(os.path.join(prefix, *f["path"]))
+                path = decode_string(os.path.join(prefix, 
decode_string(os.path.join(*f["path"]))))
                 f["index"] = index
                 paths[path] = f
 
@@ -113,7 +116,7 @@
 
             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
                 })



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"deluge-commit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/deluge-commit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to