From ee9a01ab6d12eb6b3348d169270af314f7ee4e64 Mon Sep 17 00:00:00 2001 From: Marcos Pinto Date: Tue, 28 Aug 2007 23:38:58 +0000 Subject: [PATCH] more speedlimiter persistence fixes/tweaks --- plugins/SpeedLimiter/__init__.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/plugins/SpeedLimiter/__init__.py b/plugins/SpeedLimiter/__init__.py index 0a08acf04..7bc5c2027 100644 --- a/plugins/SpeedLimiter/__init__.py +++ b/plugins/SpeedLimiter/__init__.py @@ -79,15 +79,18 @@ class DesiredSpeed: unique_ID = self.core.get_torrent_unique_id(torrent) try: if self.core.unique_IDs[unique_ID].upload_rate_limit != -1: - self.core.set_per_upload_rate_limit(unique_ID, - self.core.unique_IDs[unique_ID].upload_rate_limit) - self.set_up_speeds[unique_ID] = \ - self.core.unique_IDs[unique_ID].upload_rate_limit / 1024 + value = self.core.unique_IDs[unique_ID].upload_rate_limit / 1024 + self.core.set_per_upload_rate_limit(unique_ID, value) + self.set_up_speeds[unique_ID] = value + if value not in self.config.get("up_speeds") and value >= 1: + self.config.get("up_speeds").insert(0, value) + self.config.get("up_speeds").pop() if self.core.unique_IDs[unique_ID].download_rate_limit != -1: - self.core.set_per_download_rate_limit(unique_ID, - self.core.unique_IDs[unique_ID].download_rate_limit) - self.set_down_speeds[unique_ID] = \ - self.core.unique_IDs[unique_ID].download_rate_limit / 1024 + self.core.set_per_download_rate_limit(unique_ID, value) + self.set_down_speeds[unique_ID] = value + if value not in self.config.get("down_speeds") and value >= 1: + self.config.get("down_speeds").insert(0, value) + self.config.get("down_speeds").pop() except AttributeError: pass