Skip to content

Commit

Permalink
Fix error on downloading magnetlink
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
xoriole committed Jan 24, 2024
1 parent 998b445 commit f60703b
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/tribler/core/components/libtorrent/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit f60703b

Please sign in to comment.