From 8562cad4f5b21b07142623e67f2e363c2a1cd45e Mon Sep 17 00:00:00 2001 From: Andrew Resch Date: Sun, 9 Mar 2008 02:41:02 +0000 Subject: [PATCH] Implement 'Queue finished to bottom'. --- deluge/core/torrentmanager.py | 12 +++++++++++- deluge/core/torrentqueue.py | 12 ++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/deluge/core/torrentmanager.py b/deluge/core/torrentmanager.py index 77aee9121..66f08333c 100644 --- a/deluge/core/torrentmanager.py +++ b/deluge/core/torrentmanager.py @@ -564,8 +564,18 @@ class TorrentManager(component.Component): # Get the torrent_id torrent_id = str(alert.handle.info_hash()) log.debug("%s is finished..", torrent_id) + # Queue to bottom if enabled + if alert.msg() == "torrent has finished downloading": + if self.config["queue_finished_to_bottom"]: + self.queue.bottom(torrent_id) + # Set the torrent state - self.torrents[torrent_id].set_state("Seeding") + if self.queue.get_num_seeding() < self.config["max_active_seeding"] or\ + self.config["max_active_seeding"] == -1: + self.torrents[torrent_id].set_state("Seeding") + else: + self.torrents[torrent_id].set_state("Queued") + # Write the fastresume file self.torrents[torrent_id].write_fastresume() diff --git a/deluge/core/torrentqueue.py b/deluge/core/torrentqueue.py index b52f4cd64..3cac716c3 100644 --- a/deluge/core/torrentqueue.py +++ b/deluge/core/torrentqueue.py @@ -51,6 +51,12 @@ class TorrentQueue(component.Component): self.torrents = component.get("TorrentManager") self.config = ConfigManager("core.conf") + # Register config set functions + self.config.register_set_function("max_active_seeding", + self._on_set_max_active_seeding, False) + self.config.register_set_function("max_active_downloading", + self._on_set_max_active_downloading, False) + def update(self): self.update_state_lists() self.update_max_active() @@ -278,3 +284,9 @@ class TorrentQueue(component.Component): self.append(self.queue.pop(index)) self.update_order() return True + + def _on_set_max_active_seeding(self, key, value): + self.update() + + def _on_set_max_active_downloading(self, key, value): + self.update()