Fix #350 stop seeds when stop ratio is reached

This commit is contained in:
Andrew Resch 2008-07-17 22:09:30 +00:00
parent 9b60cdd241
commit 553ccd0a38
3 changed files with 609 additions and 601 deletions

View File

@ -507,8 +507,13 @@ class Torrent:
if self.handle.is_finished():
# If the torrent has already reached it's 'stop_seed_ratio' then do not do anything
if self.config["stop_seed_at_ratio"]:
if self.get_ratio() >= self.config["stop_seed_ratio"]:
if self.config["stop_seed_at_ratio"] or self.stop_at_ratio:
if self.stop_at_ratio:
ratio = self.stop_ratio
else:
ratio = self.config["stop_seed_ratio"]
if self.get_ratio() >= ratio:
self.signals.emit("torrent_resume_at_stop_ratio")
return

View File

@ -180,13 +180,15 @@ class TorrentManager(component.Component):
self.alerts.handle_alerts(True)
def update(self):
for torrent in self.torrents:
for torrent_id, torrent in self.torrents.items():
if self.config["stop_seed_at_ratio"] or torrent.stop_at_ratio:
if (torrent.get_ratio() >= self.config["stop_seed_ratio"] or\
torrent.get_ratio() > torrent.stop_ratio) and torrent.is_finished:
stop_ratio = self.config["stop_seed_ratio"]
if torrent.stop_at_ratio:
stop_ratio = torrent.stop_ratio
if torrent.get_ratio() >= stop_ratio and torrent.is_finished:
torrent.pause()
if self.config["remove_seed_at_ratio"] or torrent.remove_at_ratio:
self.remove(torrent.torrent_id)
self.remove(torrent_id)
def __getitem__(self, torrent_id):
"""Return the Torrent with torrent_id"""

File diff suppressed because it is too large Load Diff