diff --git a/deluge/core/core.py b/deluge/core/core.py index 8af996343..1201ff276 100644 --- a/deluge/core/core.py +++ b/deluge/core/core.py @@ -212,6 +212,12 @@ class Core(dbus.service.Object): # Emit the torrent_removed signal self.torrent_removed(torrent_id) + @dbus.service.method(dbus_interface="org.deluge_torrent.Deluge", + in_signature="s", out_signature="") + def force_reannounce(self, torrent_id): + log.debug("Forcing reannouncment to trackers of torrent %s", torrent_id) + self.torrents.force_reannounce(torrent_id) + @dbus.service.method(dbus_interface="org.deluge_torrent.Deluge", in_signature="s", out_signature="") def pause_torrent(self, torrent_id): diff --git a/deluge/core/torrentmanager.py b/deluge/core/torrentmanager.py index baf6e7c55..824176d0c 100644 --- a/deluge/core/torrentmanager.py +++ b/deluge/core/torrentmanager.py @@ -197,6 +197,16 @@ class TorrentManager: return True + def force_reannounce(self, torrent_id): + """Resume a torrent""" + try: + self.torrents[torrent_id].handle.force_reannounce() + except: + return False + + return True + + def load_state(self): """Load the state of the TorrentManager from the torrents.state file""" state = TorrentManagerState() diff --git a/deluge/ui/functions.py b/deluge/ui/functions.py index 304f729d0..b05f29208 100644 --- a/deluge/ui/functions.py +++ b/deluge/ui/functions.py @@ -122,6 +122,12 @@ def resume_torrent(torrent_ids): for torrent_id in torrent_ids: core.resume_torrent(torrent_id) +def force_reannounce(torrent_ids): + """Reannounce to trackers""" + core = get_core() + for torrent_id in torrent_ids: + core.force_reannounce(torrent_id) + def get_torrent_status(core, torrent_id, keys): """Builds the status dictionary and returns it""" status = core.get_torrent_status(torrent_id, keys) diff --git a/deluge/ui/gtkui/menubar.py b/deluge/ui/gtkui/menubar.py index 85e17d09c..345af06af 100644 --- a/deluge/ui/gtkui/menubar.py +++ b/deluge/ui/gtkui/menubar.py @@ -137,6 +137,8 @@ class MenuBar: def on_menuitem_updatetracker_activate(self, data=None): log.debug("on_menuitem_updatetracker_activate") + functions.force_reannounce( + self.window.torrentview.get_selected_torrents()) def on_menuitem_edittrackers_activate(self, data=None): log.debug("on_menuitem_edittrackers_activate")