diff options
author | Marcos Pinto <markybob@dipconsultants.com> | 2007-10-23 02:43:21 +0000 |
---|---|---|
committer | Marcos Pinto <markybob@dipconsultants.com> | 2007-10-23 02:43:21 +0000 |
commit | d33923d77ce49a03a99867e3f53a62fe71357842 (patch) | |
tree | f6caed91b6c1623179f39baa1ca63492c9a55d0e | |
parent | 5b762efa86905f9e2a45777bf4204d5a9b5a723e (diff) | |
download | deluge-d33923d77ce49a03a99867e3f53a62fe71357842.tar.gz deluge-d33923d77ce49a03a99867e3f53a62fe71357842.tar.bz2 deluge-d33923d77ce49a03a99867e3f53a62fe71357842.zip |
ratio fix
-rw-r--r-- | src/core.py | 11 | ||||
-rw-r--r-- | src/interface.py | 9 |
2 files changed, 13 insertions, 7 deletions
diff --git a/src/core.py b/src/core.py index 3c27366cd..964414fc3 100644 --- a/src/core.py +++ b/src/core.py @@ -162,6 +162,7 @@ class torrent_info: self.compact = compact self.user_paused = False self.uploaded_memory = 0 + self.initial_uploaded_memory = 0 self.upload_rate_limit = 0 self.download_rate_limit = 0 self.webseed_urls = [] @@ -278,9 +279,6 @@ class Manager: self.state = persistent_state() def quit(self): - # Analyze data needed for pickling, etc. - self.pre_quitting() - # Pickle the prefs print "Saving prefs..." self.config.save() @@ -313,11 +311,12 @@ class Manager: pickle.dump(self.state, output) output.close() - def pre_quitting(self): + def save_upmem(self): # Save the uploaded data from this session to the existing upload memory for unique_ID in self.unique_IDs.keys(): # self.get_core_torrent_state purposefully not cached. - self.unique_IDs[unique_ID].uploaded_memory += \ + self.unique_IDs[unique_ID].uploaded_memory = \ + self.unique_IDs[unique_ID].initial_uploaded_memory + \ self.get_core_torrent_state(unique_ID, False)['total_upload'] # Preference management functions @@ -982,7 +981,7 @@ class Manager: # Calculations def calc_ratio(self, unique_ID, torrent_state): - up = float((torrent_state['total_payload_upload'] / 1024) + (self.unique_IDs[unique_ID].uploaded_memory / 1024)) + up = float(self.unique_IDs[unique_ID].uploaded_memory / 1024) down = float(torrent_state["total_done"] / 1024) try: ret = up/down diff --git a/src/interface.py b/src/interface.py index f112c87e4..a8eb5ad6e 100644 --- a/src/interface.py +++ b/src/interface.py @@ -161,6 +161,7 @@ class DelugeGTK: self.dht_timer = 0 self.dht_skip = False + self.memory_timer = 0 def connect_signals(self): self.wtree.signal_autoconnect({ @@ -962,6 +963,9 @@ window, please enter your password")) if self.manager.unique_IDs[unique_id].trackers: self.manager.replace_trackers(unique_id, \ self.manager.unique_IDs[unique_id].trackers) + if self.manager.unique_IDs[unique_id].uploaded_memory: + self.manager.unique_IDs[unique_id].initial_uploaded_memory \ + = self.manager.unique_IDs[unique_id].uploaded_memory except AttributeError: pass @@ -981,7 +985,10 @@ window, please enter your password")) self.update_interface = self.window.get_property("visible") and not \ self.is_minimized - + self.memory_timer += 1 + if (self.memory_timer == 60): + self.manager.save_upmem() + self.memory_timer = 0 # Handle the events self.manager.handle_events() |