Skip to content

Commit

Permalink
Added torrent_status_changed event
Browse files Browse the repository at this point in the history
  • Loading branch information
egbertbouman committed Jun 19, 2024
1 parent c93f791 commit 3e6a3e2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/tribler/core/libtorrent/download_manager/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
1 change: 1 addition & 0 deletions src/tribler/core/notifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
1 change: 1 addition & 0 deletions src/tribler/core/restapi/events_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 3e6a3e2

Please sign in to comment.