From b7c3fddf0e20b13a046738c78629e54ff1a7fc11 Mon Sep 17 00:00:00 2001 From: Alex Dedul Date: Fri, 10 Aug 2007 03:18:25 +0000 Subject: [PATCH] Include uploaded_memory in pickle_state(). --- src/core.py | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/src/core.py b/src/core.py index 34ec246cc..a20ce1e4c 100644 --- a/src/core.py +++ b/src/core.py @@ -271,9 +271,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() @@ -293,24 +290,26 @@ class Manager: deluge_core.quit() def pickle_state(self): + # Save the uploaded data from this session to the existing upload + # memory + for unique_ID in self.unique_IDs: + # self.get_core_torrent_state purposefully not cached. + # + # self.unique_IDs[unique_ID] is a reference to torrent_info + # instance in a self.state.torrents array, so changing something + # in self.unique_IDs[unique_ID] we also changing it in + # self.state.torrents array. + self.unique_IDs[unique_ID].uploaded_memory += \ + self.get_core_torrent_state(unique_ID, False)['total_upload'] + # Pickle the state so if we experience a crash, the latest state is # available print "Pickling state..." - #print self.state.torrents - #print self.state.queue - output = open(os.path.join(self.base_dir, STATE_FILENAME), 'wb') pickle.dump(self.state, output) output.close() - def pre_quitting(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.get_core_torrent_state(unique_ID, False)['total_upload'] - # Preference management functions def get_config(self): @@ -893,7 +892,6 @@ class Manager: def get_queue_index(self, unique_ID): return self.state.queue.index(unique_ID) - def apply_prefs(self): print "Applying preferences"