From de4fbd2e8223031484d439ca99bce89785ea5db3 Mon Sep 17 00:00:00 2001 From: Calum Lind Date: Sun, 26 Sep 2021 19:18:45 +0100 Subject: [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::flags::bitfield_flag flags=0) ``` Should be fixed in 2.0.5 release: https://github.com/arvidn/libtorrent/commit/3feba04e6d --- deluge/core/torrent.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/deluge/core/torrent.py b/deluge/core/torrent.py index d7dab95bf..ede5200f0 100644 --- a/deluge/core/torrent.py +++ b/deluge/core/torrent.py @@ -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): -- cgit