From f60703b4711a77c6acd5bc278b8e2cc2c71af3af Mon Sep 17 00:00:00 2001 From: Sandip Pandey Date: Wed, 24 Jan 2024 14:06:08 +0100 Subject: [PATCH] Fix error on downloading magnetlink The issue was caused by a bug on creating TorrentDefNoMetainfo object. With the latest change, the name field is made binary. This PR addresses the changes. --- .../components/libtorrent/download_manager/download_manager.py | 2 +- src/tribler/core/components/libtorrent/tests/conftest.py | 2 +- src/tribler/core/components/libtorrent/tests/test_download.py | 2 +- .../core/components/libtorrent/tests/test_download_manager.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/tribler/core/components/libtorrent/download_manager/download_manager.py b/src/tribler/core/components/libtorrent/download_manager/download_manager.py index 1edb4a42104..7ea1543500a 100644 --- a/src/tribler/core/components/libtorrent/download_manager/download_manager.py +++ b/src/tribler/core/components/libtorrent/download_manager/download_manager.py @@ -511,7 +511,7 @@ async def get_metainfo(self, infohash: bytes, timeout: float = 30, hops: Optiona elif infohash in self.downloads: download = self.downloads[infohash] else: - tdef = TorrentDefNoMetainfo(infohash, 'metainfo request', url=url) + tdef = TorrentDefNoMetainfo(infohash, b'metainfo request', url=url) dcfg = DownloadConfig() dcfg.set_hops(hops or self.download_defaults.number_hops) dcfg.set_upload_mode(True) # Upload mode should prevent libtorrent from creating files diff --git a/src/tribler/core/components/libtorrent/tests/conftest.py b/src/tribler/core/components/libtorrent/tests/conftest.py index 28f4dbecc79..6534d8e0a60 100644 --- a/src/tribler/core/components/libtorrent/tests/conftest.py +++ b/src/tribler/core/components/libtorrent/tests/conftest.py @@ -5,7 +5,7 @@ @pytest.fixture def test_tdef_no_metainfo(state_dir): - tdef = TorrentDefNoMetainfo(b"1" * 20, "test") + tdef = TorrentDefNoMetainfo(b"1" * 20, b"test") return tdef diff --git a/src/tribler/core/components/libtorrent/tests/test_download.py b/src/tribler/core/components/libtorrent/tests/test_download.py index c95ef14a1a8..6ba9dee6dde 100644 --- a/src/tribler/core/components/libtorrent/tests/test_download.py +++ b/src/tribler/core/components/libtorrent/tests/test_download.py @@ -541,7 +541,7 @@ async def test_apply_ip_filter(test_download, mock_handle): # pylint: disable=u await test_download.apply_ip_filter(True) test_download.handle.apply_ip_filter.assert_called_with(True) - test_download.tdef = TorrentDefNoMetainfo(b'a' * 20, 'metainfo request') + test_download.tdef = TorrentDefNoMetainfo(b'a' * 20, b'metainfo request') test_download.handle.reset_mock() test_download.apply_ip_filter(False) test_download.handle.apply_ip_filter.assert_not_called() diff --git a/src/tribler/core/components/libtorrent/tests/test_download_manager.py b/src/tribler/core/components/libtorrent/tests/test_download_manager.py index bc13726af07..1f4bb60492e 100644 --- a/src/tribler/core/components/libtorrent/tests/test_download_manager.py +++ b/src/tribler/core/components/libtorrent/tests/test_download_manager.py @@ -312,7 +312,7 @@ async def test_start_download_existing_download(fake_dlmgr): fake_dlmgr.get_session = lambda *_: mock_ltsession download = await fake_dlmgr.start_download( - tdef=TorrentDefNoMetainfo(infohash, "name"), checkpoint_disabled=True + tdef=TorrentDefNoMetainfo(infohash, b"name"), checkpoint_disabled=True ) assert download == mock_download fake_dlmgr.downloads.clear()