Implement 'Queue finished to bottom'.

This commit is contained in:
Andrew Resch 2008-03-09 02:41:02 +00:00
parent def92cb735
commit 8562cad4f5
2 changed files with 23 additions and 1 deletions

View File

@ -564,8 +564,18 @@ class TorrentManager(component.Component):
# Get the torrent_id # Get the torrent_id
torrent_id = str(alert.handle.info_hash()) torrent_id = str(alert.handle.info_hash())
log.debug("%s is finished..", torrent_id) 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 # 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 # Write the fastresume file
self.torrents[torrent_id].write_fastresume() self.torrents[torrent_id].write_fastresume()

View File

@ -51,6 +51,12 @@ class TorrentQueue(component.Component):
self.torrents = component.get("TorrentManager") self.torrents = component.get("TorrentManager")
self.config = ConfigManager("core.conf") 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): def update(self):
self.update_state_lists() self.update_state_lists()
self.update_max_active() self.update_max_active()
@ -278,3 +284,9 @@ class TorrentQueue(component.Component):
self.append(self.queue.pop(index)) self.append(self.queue.pop(index))
self.update_order() self.update_order()
return True return True
def _on_set_max_active_seeding(self, key, value):
self.update()
def _on_set_max_active_downloading(self, key, value):
self.update()