mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-04 07:28:39 +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) ===
|
=== Deluge 1.1.7 - (In Development) ===
|
||||||
==== GtkUI ====
|
==== GtkUI ====
|
||||||
* Fix #883 segfault if locale is not using UTF-8 encoding
|
* 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) ===
|
=== Deluge 1.1.6 - (06 April 2009) ===
|
||||||
==== Core ====
|
==== Core ====
|
||||||
|
|
|
@ -271,13 +271,17 @@ class BaseClient(object):
|
||||||
# Open the .torrent file for reading because we need to send it's
|
# Open the .torrent file for reading because we need to send it's
|
||||||
# contents to the core.
|
# contents to the core.
|
||||||
try:
|
try:
|
||||||
f = open(unicode(torrent_file), "rb")
|
f = open(torrent_file, "rb")
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
log.warning("Unable to open %s: %s", torrent_file, e)
|
log.warning("Unable to open %s: %s", torrent_file, e)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Get the filename because the core doesn't want a path.
|
# Get the name of the torrent from the TorrentInfo object because
|
||||||
(path, filename) = os.path.split(torrent_file)
|
# 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())
|
fdump = xmlrpclib.Binary(f.read())
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
|
|
|
@ -62,6 +62,8 @@ class TorrentInfo(object):
|
||||||
self.encoding = "UTF-8"
|
self.encoding = "UTF-8"
|
||||||
if "encoding" in self.__m_metadata:
|
if "encoding" in self.__m_metadata:
|
||||||
self.encoding = self.__m_metadata["encoding"]
|
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
|
# Get list of files from torrent info
|
||||||
self.__m_files = []
|
self.__m_files = []
|
||||||
|
|
|
@ -186,14 +186,12 @@ class AddTorrentDialog(component.Component):
|
||||||
new_row = None
|
new_row = None
|
||||||
|
|
||||||
for filename in filenames:
|
for filename in filenames:
|
||||||
# Convert the path to unicode
|
|
||||||
filename = unicode(filename)
|
|
||||||
|
|
||||||
# Get the torrent data from the torrent file
|
# Get the torrent data from the torrent file
|
||||||
try:
|
try:
|
||||||
info = deluge.ui.common.TorrentInfo(filename)
|
info = deluge.ui.common.TorrentInfo(filename)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
log.debug("Unable to open torrent file: %s", e)
|
log.debug("Unable to open torrent file: %s", e)
|
||||||
|
log.exception(e)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if info.info_hash in self.files:
|
if info.info_hash in self.files:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue