[Core] Workaround torrent file_progress lt 2.0 error

Workaround lt 2.0 python bindings error when calling a torrent handle
file_progress:

```
Boost.Python.ArgumentError: Python argument types in
    torrent_handle.file_progress(torrent_handle)
did not match C++ signature:
    file_progress(libtorrent::torrent_handle {lvalue}, libtorrent:🎏:bitfield_flag<unsigned char, libtorrent::file_progress_flags_tag, void> flags=0)
```

Should be fixed in 2.0.5 release: https://github.com/arvidn/libtorrent/commit/3feba04e6d
This commit is contained in:
Calum Lind 2021-09-26 19:18:45 +01:00
parent 9c3982d4ff
commit de4fbd2e82
1 changed files with 10 additions and 3 deletions

View File

@ -874,11 +874,18 @@ class Torrent(object):
"""
if not self.has_metadata:
return []
return [
progress / _file.size if _file.size else 0.0
for progress, _file in zip(
try:
files_progresses = zip(
self.handle.file_progress(), self.torrent_info.files()
)
except Exception:
# Handle libtorrent >=2.0.0,<=2.0.4 file_progress error
files_progresses = zip(iter(lambda: 0, 1), self.torrent_info.files())
return [
progress / _file.size if _file.size else 0.0
for progress, _file in files_progresses
]
def get_tracker_host(self):