diff options
author | Calum Lind <calumlind+deluge@gmail.com> | 2021-09-26 19:18:45 +0100 |
---|---|---|
committer | Calum Lind <calumlind+deluge@gmail.com> | 2021-10-03 18:53:31 +0100 |
commit | de4fbd2e8223031484d439ca99bce89785ea5db3 (patch) | |
tree | c70fbdae8b29fa1cfcedc9dcffac0a0e55e028f4 | |
parent | 9c3982d4ffc81364839cc37c57572be562bb47dc (diff) | |
download | deluge-de4fbd2e8223031484d439ca99bce89785ea5db3.tar.gz deluge-de4fbd2e8223031484d439ca99bce89785ea5db3.tar.bz2 deluge-de4fbd2e8223031484d439ca99bce89785ea5db3.zip |
[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<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
-rw-r--r-- | deluge/core/torrent.py | 13 |
1 files 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): |