diff options
author | Calum Lind <calumlind+deluge@gmail.com> | 2022-07-03 09:54:03 +0100 |
---|---|---|
committer | Calum Lind <calumlind+deluge@gmail.com> | 2022-07-05 08:03:33 +0100 |
commit | f52cf760e4934f1270c077305a479a9d2ec5fd47 (patch) | |
tree | 1a1a003b2c176d26d73b64bd5ce4428d80b9c612 /deluge | |
parent | 94d790c159a06755076d1e8e0d16d40c3305bb07 (diff) | |
download | deluge-f52cf760e4934f1270c077305a479a9d2ec5fd47.tar.gz deluge-f52cf760e4934f1270c077305a479a9d2ec5fd47.tar.bz2 deluge-f52cf760e4934f1270c077305a479a9d2ec5fd47.zip |
Fix missing trackers adding magnets
The changes to remove deprecated lt methods didn't account for magnet
trackers so magnets are missing trackers when added.
Previously the addition of trackers was handled by libtorrent when a url
was passed in add_torrent_params. The url parameter is deprecated so
instead we need to add both the info_hash and trackers.
Trac: https://dev.deluge-torrent.org/ticket/3530
Diffstat (limited to 'deluge')
-rw-r--r-- | deluge/core/torrentmanager.py | 2 | ||||
-rw-r--r-- | deluge/tests/test_core.py | 7 |
2 files changed, 7 insertions, 2 deletions
diff --git a/deluge/core/torrentmanager.py b/deluge/core/torrentmanager.py index 4904e94ed..5609df4bd 100644 --- a/deluge/core/torrentmanager.py +++ b/deluge/core/torrentmanager.py @@ -436,8 +436,8 @@ class TorrentManager(component.Component): magnet_info = get_magnet_info(magnet) if magnet_info: add_torrent_params['name'] = magnet_info['name'] + add_torrent_params['trackers'] = list(magnet_info['trackers']) torrent_id = magnet_info['info_hash'] - # Workaround lt 1.2 bug for magnet resume data with no metadata add_torrent_params['info_hash'] = bytes(bytearray.fromhex(torrent_id)) else: raise AddTorrentError( diff --git a/deluge/tests/test_core.py b/deluge/tests/test_core.py index f1c2e3be8..6a3fb9506 100644 --- a/deluge/tests/test_core.py +++ b/deluge/tests/test_core.py @@ -222,10 +222,15 @@ class TestCore(BaseTestCase): @pytest_twisted.inlineCallbacks def test_add_torrent_magnet(self): info_hash = '60d5d82328b4547511fdeac9bf4d0112daa0ce00' - uri = deluge.common.create_magnet_uri(info_hash) + tracker = 'udp://tracker.example.com' + name = 'test magnet' + uri = deluge.common.create_magnet_uri(info_hash, name=name, trackers=[tracker]) options = {} torrent_id = yield self.core.add_torrent_magnet(uri, options) assert torrent_id == info_hash + torrent_status = self.core.get_torrent_status(torrent_id, ['name', 'trackers']) + assert torrent_status['trackers'][0]['url'] == tracker + assert torrent_status['name'] == name def test_resume_torrent(self): tid1 = self.add_torrent('test.torrent', paused=True) |