mirror of
https://github.com/codex-storage/deluge.git
synced 2025-02-17 13:56:47 +00:00
Fix adding torrents with different metadata by storing the bencoded dict too. If we bencode the stored metadata dict, there is a chance the order of the dict will be different and change the info-hash.
This commit is contained in:
parent
634ecdeb1d
commit
1f58910a38
@ -84,7 +84,8 @@ class TorrentInfo(object):
|
|||||||
# Get the torrent data from the torrent file
|
# Get the torrent data from the torrent file
|
||||||
try:
|
try:
|
||||||
log.debug("Attempting to open %s.", filename)
|
log.debug("Attempting to open %s.", filename)
|
||||||
self.__m_metadata = bencode.bdecode(open(filename, "rb").read())
|
self.__m_filedata = open(filename, "rb").read()
|
||||||
|
self.__m_metadata = bencode.bdecode(self.__m_filedata)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
log.warning("Unable to open %s: %s", filename, e)
|
log.warning("Unable to open %s: %s", filename, e)
|
||||||
raise e
|
raise e
|
||||||
@ -212,6 +213,16 @@ class TorrentInfo(object):
|
|||||||
"""
|
"""
|
||||||
return self.__m_metadata
|
return self.__m_metadata
|
||||||
|
|
||||||
|
@property
|
||||||
|
def filedata(self):
|
||||||
|
"""
|
||||||
|
The torrents file data. This will be the bencoded dictionary read
|
||||||
|
from the torrent file.
|
||||||
|
|
||||||
|
:rtype: string
|
||||||
|
"""
|
||||||
|
return self.__m_filedata
|
||||||
|
|
||||||
class FileTree(object):
|
class FileTree(object):
|
||||||
"""
|
"""
|
||||||
Convert a list of paths in a file tree.
|
Convert a list of paths in a file tree.
|
||||||
|
@ -211,7 +211,7 @@ class AddTorrentDialog(component.Component):
|
|||||||
new_row = self.torrent_liststore.append(
|
new_row = self.torrent_liststore.append(
|
||||||
[info.info_hash, info.name, filename])
|
[info.info_hash, info.name, filename])
|
||||||
self.files[info.info_hash] = info.files
|
self.files[info.info_hash] = info.files
|
||||||
self.infos[info.info_hash] = info.metadata
|
self.infos[info.info_hash] = info.filedata
|
||||||
self.listview_torrents.get_selection().select_iter(new_row)
|
self.listview_torrents.get_selection().select_iter(new_row)
|
||||||
|
|
||||||
self.set_default_options()
|
self.set_default_options()
|
||||||
@ -737,10 +737,9 @@ class AddTorrentDialog(component.Component):
|
|||||||
del options["file_priorities"]
|
del options["file_priorities"]
|
||||||
client.core.add_torrent_magnet(filename, options)
|
client.core.add_torrent_magnet(filename, options)
|
||||||
else:
|
else:
|
||||||
from deluge.bencode import bencode
|
|
||||||
client.core.add_torrent_file(
|
client.core.add_torrent_file(
|
||||||
os.path.split(filename)[-1],
|
os.path.split(filename)[-1],
|
||||||
base64.encodestring(bencode(self.infos[torrent_id])),
|
base64.encodestring(self.infos[torrent_id]),
|
||||||
options)
|
options)
|
||||||
|
|
||||||
row = self.torrent_liststore.iter_next(row)
|
row = self.torrent_liststore.iter_next(row)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user