Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error on downloading magnetlink #7851

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the fix. The name field is expected to be bytes.

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
Loading