mirror of
https://git.deluge-torrent.org/deluge
synced 2025-04-20 19:44:52 +00:00
Fix for adding torrents with invalid filename encodings
This commit is contained in:
parent
2023fac5c5
commit
1693bc7373
4 changed files with 11 additions and 6 deletions
|
@ -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 ====
|
||||
|
|
|
@ -271,13 +271,17 @@ class BaseClient(object):
|
|||
# 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()
|
||||
|
||||
|
|
|
@ -62,6 +62,8 @@ class TorrentInfo(object):
|
|||
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 = []
|
||||
|
|
|
@ -186,14 +186,12 @@ class AddTorrentDialog(component.Component):
|
|||
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:
|
||||
|
|
Loading…
Add table
Reference in a new issue