Skip to content

Commit

Permalink
Update libtorrent to 2.0.9
Browse files Browse the repository at this point in the history
Also pinned to older version of marshmallow
  • Loading branch information
qstokkink committed Jan 7, 2025
1 parent 47cbe16 commit a99896f
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/unittests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
- shell: bash
run: |
cp /opt/homebrew/opt/libsodium/lib/libsodium.dylib /Library/Frameworks/Python.framework/Versions/3.9/lib/libsodium.dylib
sed -i".backup" 's|libtorrent==1.2.19|https://tribler.org/libtorrent-2.0.11-cp39-cp39-macosx_14_0_arm64.whl|' requirements.txt
sed -i".backup" 's|libtorrent==2.0.9|https://tribler.org/libtorrent-2.0.11-cp39-cp39-macosx_14_0_arm64.whl|' requirements.txt
- run: python -m pip install -r requirements.txt
- name: Run unit tests
run: |
Expand Down
2 changes: 1 addition & 1 deletion build/docker/build.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# libtorrent-1.2.19 does not support python 3.11 yet
# libtorrent-2.0.9 does not support python 3.11 yet
FROM python:3.10-slim

RUN apt-get update \
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
bitarray
configobj
ipv8-rust-tunnels
libtorrent==1.2.19
libtorrent==2.0.9
lz4
marshmallow==3.23.3 # TODO: support 3.24.0 onward
pillow
pony
pystray
Expand Down
12 changes: 4 additions & 8 deletions src/tribler/core/libtorrent/download_manager/download_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,8 @@ def create_session(self, hops: int = 0) -> lt.session: # noqa: PLR0915
"enable_upnp": int(self.config.get("libtorrent/upnp")),
"enable_dht": int(self.config.get("libtorrent/dht")),
"enable_lsd": int(self.config.get("libtorrent/lsd")),
"enable_natpmp": int(self.config.get("libtorrent/natpmp"))}
"enable_natpmp": int(self.config.get("libtorrent/natpmp")),
"allow_i2p_mixed": 1}

# Copy construct so we don't modify the default list
extensions = list(DEFAULT_LT_EXTENSIONS)
Expand Down Expand Up @@ -633,13 +634,8 @@ async def start_download_from_uri(self, uri: str, config: DownloadConfig | None
if scheme == "magnet":
logger.info("Magnet scheme detected")
params = lt.parse_magnet_uri(uri)
try:
# libtorrent 1.2.19
name, infohash = params["name"].encode(), params["info_hash"] # type: ignore[index] # (checker is 2.X)
except TypeError:
# libtorrent 2.0.9
name = params.name.encode()
infohash = unhexlify(str(params.info_hash))
name = params.name.encode()
infohash = unhexlify(str(params.info_hash))
logger.info("Name: %s. Infohash: %s", name, infohash)
if infohash in self.metainfo_cache:
logger.info("Metainfo found in cache")
Expand Down
14 changes: 2 additions & 12 deletions src/tribler/core/libtorrent/restapi/torrentinfo_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,7 @@ async def get_torrent_info(self, request: Request) -> RESTResponse: # noqa: C90

if response.startswith(b'magnet'):
try:
try:
# libtorrent 1.2.19
infohash = lt.parse_magnet_uri(uri)["info_hash"] # type: ignore[index] # (checker uses 2.X)
except TypeError:
# libtorrent 2.0.9
infohash = unhexlify(str(lt.parse_magnet_uri(uri).info_hash))
infohash = unhexlify(str(lt.parse_magnet_uri(uri).info_hash))
except RuntimeError as e:
return RESTResponse(
{"error": {
Expand All @@ -203,12 +198,7 @@ async def get_torrent_info(self, request: Request) -> RESTResponse: # noqa: C90
self._logger.info("magnet scheme detected")

try:
try:
# libtorrent 1.2.19
infohash = lt.parse_magnet_uri(uri)["info_hash"] # type: ignore[index] # (checker uses 2.X)
except TypeError:
# libtorrent 2.0.9
infohash = unhexlify(str(lt.parse_magnet_uri(uri).info_hash))
infohash = unhexlify(str(lt.parse_magnet_uri(uri).info_hash))
except RuntimeError as e:
return RESTResponse(
{"error": {
Expand Down

0 comments on commit a99896f

Please sign in to comment.