Skip to content

fix: read has_metadata from torrent status - #288

Merged
stabldev merged 3 commits into
stabldev:mainfrom
vaibhav8a:fix/libtorrent-21-has-metadata
Aug 15, 2026
Merged

fix: read has_metadata from torrent status#288
stabldev merged 3 commits into
stabldev:mainfrom
vaibhav8a:fix/libtorrent-21-has-metadata

Conversation

@vaibhav8a

Copy link
Copy Markdown
Contributor

Fixes #285

Problem

check_metadata_updates() calls handle.has_metadata(). That method is deprecated upstream and is compiled out of libtorrent builds configured without deprecated functions — which is how Arch ships libtorrent-rasterbar 2.1. On those builds the call raises:

AttributeError: 'torrent_handle' object has no attribute 'has_metadata'

pyproject.toml declares libtorrent>=2.0.11, so 2.1 is inside the supported range.

Fix

Read the same information from handle.status().has_metadata, which is present on every supported version.

Verification

Confirmed against libtorrent 2.1.1 on a real torrent_handle built from a magnet URI:

DeprecationWarning: has_metadata() is deprecated
handle.has_metadata():   False
status().has_metadata:   False

Same value, and the deprecation warning goes away. On the PyPI build the old call still exists but is deprecated; on Arch's build it is absent entirely, which is the crash in the report.

Test suite: 36 passed, 3 errors before and after this change — the 3 are tests/snapshots needing the snap_compare fixture (pytest-textual-snapshot not installed locally) and are unrelated.

torrent_handle.has_metadata() is deprecated upstream and is compiled out of
builds configured without deprecated functions, which is how Arch ships
libtorrent-rasterbar 2.1. On those builds check_metadata_updates() raises
AttributeError: 'torrent_handle' object has no attribute 'has_metadata'.

torrent_status.has_metadata carries the same information and is present on
every version the project supports (libtorrent>=2.0.11), so read it from
handle.status() instead.

Fixes stabldev#285
Comment thread src/torrra/core/download.py Outdated
@stabldev stabldev changed the title fix(download): read has_metadata from torrent status fix: read has_metadata from torrent status Aug 15, 2026
@stabldev
stabldev merged commit 70d2d0b into stabldev:main Aug 15, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Compatibility issue with libtorrent-rasterbar 2.1

2 participants