diff --git a/src/tribler/core/libtorrent/download_manager/download.py b/src/tribler/core/libtorrent/download_manager/download.py index f6c2971344..cbf638510e 100644 --- a/src/tribler/core/libtorrent/download_manager/download.py +++ b/src/tribler/core/libtorrent/download_manager/download.py @@ -573,9 +573,17 @@ def update_lt_status(self, lt_status: lt.torrent_status) -> None: """ Update libtorrent stats and check if the download should be stopped. """ - self.lt_status = lt_status + old_status = self.get_state().get_status() + self.lt_status = lt_status state = self.get_state() + + # Notify the GUI if the status has changed + if self.notifier and not self.hidden and state.get_status() != old_status: + self.notifier.notify(Notification.torrent_status_changed, + infohash=hexlify(self.tdef.get_infohash()).decode(), + status=state.get_status().name) + if state.get_status() == DownloadStatus.SEEDING: mode = self.download_manager.config.get("libtorrent/download_defaults/seeding_mode") seeding_ratio = self.download_manager.config.get("libtorrent/download_defaults/seeding_ratio") diff --git a/src/tribler/core/notifier.py b/src/tribler/core/notifier.py index afc125ed6d..55a9a5cea1 100644 --- a/src/tribler/core/notifier.py +++ b/src/tribler/core/notifier.py @@ -24,6 +24,7 @@ class Notification(Enum): """ torrent_finished = Desc("torrent_finished", ["infohash", "name", "hidden"], [str, str, bool]) + torrent_status_changed = Desc("torrent_status_changed", ["infohash", "status"], [str, str]) tribler_shutdown_state = Desc("tribler_shutdown_state", ["state"], [str]) tribler_new_version = Desc("tribler_new_version", ["version"], [str]) channel_discovered = Desc("channel_discovered", ["data"], [dict]) diff --git a/src/tribler/core/restapi/events_endpoint.py b/src/tribler/core/restapi/events_endpoint.py index b645b14ce9..b580e4ac22 100644 --- a/src/tribler/core/restapi/events_endpoint.py +++ b/src/tribler/core/restapi/events_endpoint.py @@ -19,6 +19,7 @@ from ipv8.messaging.anonymization.tunnel import Circuit topics_to_send_to_gui = [ + Notification.torrent_status_changed, Notification.tunnel_removed, Notification.watch_folder_corrupt_file, Notification.tribler_new_version,