Author: andar
Revision: 5051
Log:
Fix for adding torrents with invalid filename encodings
Diff:
Modified: branches/1.1.0_RC/ChangeLog
===================================================================
--- branches/1.1.0_RC/ChangeLog 2009-04-09 16:40:52 UTC (rev 5050)
+++ branches/1.1.0_RC/ChangeLog 2009-04-10 17:34:55 UTC (rev 5051)
@@ -1,6 +1,7 @@
=== Deluge 1.1.7 - (In Development) ===
==== GtkUI ====
* Fix #883 segfault if locale is not using UTF-8 encoding
+ * Fix for adding torrents with invalid filename encodings
=== Deluge 1.1.6 - (06 April 2009) ===
==== Core ====
Modified: branches/1.1.0_RC/deluge/ui/client.py
===================================================================
--- branches/1.1.0_RC/deluge/ui/client.py 2009-04-09 16:40:52 UTC (rev
5050)
+++ branches/1.1.0_RC/deluge/ui/client.py 2009-04-10 17:34:55 UTC (rev
5051)
@@ -271,13 +271,17 @@
# Open the .torrent file for reading because we need to send it's
# contents to the core.
try:
- f = open(unicode(torrent_file), "rb")
+ f = open(torrent_file, "rb")
except Exception, e:
log.warning("Unable to open %s: %s", torrent_file, e)
continue
- # Get the filename because the core doesn't want a path.
- (path, filename) = os.path.split(torrent_file)
+ # Get the name of the torrent from the TorrentInfo object because
+ # it does better handling of encodings
+ import deluge.ui.common
+ ti = deluge.ui.common.TorrentInfo(torrent_file)
+ filename = ti.name
+
fdump = xmlrpclib.Binary(f.read())
f.close()
Modified: branches/1.1.0_RC/deluge/ui/common.py
===================================================================
--- branches/1.1.0_RC/deluge/ui/common.py 2009-04-09 16:40:52 UTC (rev
5050)
+++ branches/1.1.0_RC/deluge/ui/common.py 2009-04-10 17:34:55 UTC (rev
5051)
@@ -62,6 +62,8 @@
self.encoding = "UTF-8"
if "encoding" in self.__m_metadata:
self.encoding = self.__m_metadata["encoding"]
+ elif "codepage" in self.__m_metadata:
+ self.encoding = str(self.__m_metadata["codepage"])
# Get list of files from torrent info
self.__m_files = []
Modified: branches/1.1.0_RC/deluge/ui/gtkui/addtorrentdialog.py
===================================================================
--- branches/1.1.0_RC/deluge/ui/gtkui/addtorrentdialog.py 2009-04-09
16:40:52 UTC (rev 5050)
+++ branches/1.1.0_RC/deluge/ui/gtkui/addtorrentdialog.py 2009-04-10
17:34:55 UTC (rev 5051)
@@ -186,14 +186,12 @@
new_row = None
for filename in filenames:
- # Convert the path to unicode
- filename = unicode(filename)
-
# Get the torrent data from the torrent file
try:
info = deluge.ui.common.TorrentInfo(filename)
except Exception, e:
log.debug("Unable to open torrent file: %s", e)
+ log.exception(e)
continue
if info.info_hash in self.files:
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---