summaryrefslogtreecommitdiffstats
path: root/deluge/core/core.py
diff options
context:
space:
mode:
authorCalum Lind <calumlind+deluge@gmail.com>2019-05-20 15:31:26 +0100
committerCalum Lind <calumlind+deluge@gmail.com>2019-05-20 16:49:25 +0100
commitc6b6902e9f3e37f5b15184eb509b48b43817a331 (patch)
tree6494447c1daab80e2b3eeb8291b7b4019234cf92 /deluge/core/core.py
parent6a5bb44d5b20c1404237bab5d5051a7ff8a26a65 (diff)
downloaddeluge-c6b6902e9f3e37f5b15184eb509b48b43817a331.tar.gz
deluge-c6b6902e9f3e37f5b15184eb509b48b43817a331.tar.bz2
deluge-c6b6902e9f3e37f5b15184eb509b48b43817a331.zip
[Core] Fix prefetch magnets missing trackers
When adding magnets that have been prefetched the tracker details were lost. A result of returning only the lt.torrent_info.metadata which does not contain full torrent details, such as trackers. - Modified torrentmanager prefetch_metadata to return dict instead of base64 encoded bencoded metadata dict... - Used a namedtuple to ease identifying tuple contents. - Updated tests to reflect changes with mock trackers added to test_torrent.file.torrent. - Refactor TorrentInfo to accept dict instead of bytes and add a class method to accept metadata dict with lists of trackers. - Rename class arg from metainfo to torrent_file, matching lt.torrent_info. - Rename metadata property to correct name; metainfo. - Simplify class variable naming with _filedata and _metainfo for torrent file contents encoded and decoded respectively. - Update GTK Add torrent dialog to pass trackers to TorrentInfo.
Diffstat (limited to 'deluge/core/core.py')
-rw-r--r--deluge/core/core.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/deluge/core/core.py b/deluge/core/core.py
index 91f9b8a38..9a19e3057 100644
--- a/deluge/core/core.py
+++ b/deluge/core/core.py
@@ -437,22 +437,22 @@ class Core(component.Component):
@export
def prefetch_magnet_metadata(self, magnet, timeout=30):
- """Download the metadata for the magnet uri without adding torrent to deluge session.
+ """Download magnet metadata without adding to Deluge session.
+
+ Used by UIs to get magnet files for selection before adding to session.
Args:
magnet (str): The magnet uri.
- timeout (int): Time to wait to recieve metadata from peers.
+ timeout (int): Number of seconds to wait before cancelling request.
Returns:
- Deferred: A tuple of (torrent_id (str), metadata (bytes)) for the magnet.
-
- The metadata is base64 encoded.
+ Deferred: A tuple of (torrent_id (str), metadata (dict)) for the magnet.
"""
def on_metadata(result, result_d):
- torrent_id, metadata = result
- result_d.callback((torrent_id, b64encode(metadata)))
+ """Return result of torrent_id and metadata"""
+ result_d.callback(result)
return result
d = self.torrentmanager.prefetch_metadata(magnet, timeout)