Fix setting max active torrents to unlimited to actually work.

This commit is contained in:
Andrew Resch 2008-03-09 00:27:32 +00:00
commit c1787e2520
2 changed files with 14 additions and 5 deletions

View file

@ -360,14 +360,16 @@ class Torrent:
elif self.state == "Queued": elif self.state == "Queued":
if self.handle.is_seed(): if self.handle.is_seed():
if self.torrentqueue.get_num_seeding() < self.config["max_active_seeding"]: if self.torrentqueue.get_num_seeding() < self.config["max_active_seeding"] or\
self.config["max_active_seeding"] == -1:
self.handle.resume() self.handle.resume()
self.state = "Seeding" self.state = "Seeding"
self.torrentqueue.update_order() self.torrentqueue.update_order()
else: else:
return False return False
else: else:
if self.torrentqueue.get_num_downloading() < self.config["max_active_downloading"]: if self.torrentqueue.get_num_downloading() < self.config["max_active_downloading"] or\
self.config["max_active_downloading"] == -1:
self.handle.resume() self.handle.resume()
self.state = "Downloading" self.state = "Downloading"
self.torrentqueue.update_order() self.torrentqueue.update_order()

View file

@ -118,9 +118,13 @@ class TorrentQueue(component.Component):
else: else:
to_unqueue = self.queued_seeding to_unqueue = self.queued_seeding
for (pos, torrent_id) in to_unqueue: for (pos, torrent_id) in to_unqueue:
#self.torrents[torrent_id].set_state("Seeding")
self.torrents[torrent_id].resume() self.torrents[torrent_id].resume()
else:
# The max_active_seeding is set to unlimited, so lets make sure
# all queued seeds are activated.
for (pos, torrent_id) in self.queued_seeding:
self.torrents[torrent_id].resume()
if self.config["max_active_downloading"] > -1: if self.config["max_active_downloading"] > -1:
if len(self.downloading) > self.config["max_active_downloading"]: if len(self.downloading) > self.config["max_active_downloading"]:
num_to_queue = len(self.downloading) - self.config["max_active_downloading"] num_to_queue = len(self.downloading) - self.config["max_active_downloading"]
@ -135,8 +139,11 @@ class TorrentQueue(component.Component):
else: else:
to_unqueue = self.queued_downloading to_unqueue = self.queued_downloading
for (pos, torrent_id) in to_unqueue: for (pos, torrent_id) in to_unqueue:
#self.torrents[torrent_id].set_state("Downloading")
self.torrents[torrent_id].resume() self.torrents[torrent_id].resume()
else:
# Unlimited downloading torrents set
for (pos, torrent_id) in self.queued_downloading:
self.torrents[torrent_id].resume()
def set_size(self, size): def set_size(self, size):
"""Clear and set the self.queue list to the length of size""" """Clear and set the self.queue list to the length of size"""