From ff08e28470e7152d4801919a0a50bf9cd1d0a2e8 Mon Sep 17 00:00:00 2001 From: Alex Dedul Date: Fri, 10 Aug 2007 03:23:45 +0000 Subject: [PATCH] Revert last, needs more thought. --- src/core.py | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/core.py b/src/core.py index a20ce1e4c..b0a94faa7 100644 --- a/src/core.py +++ b/src/core.py @@ -271,6 +271,9 @@ 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() @@ -290,18 +293,6 @@ 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..." @@ -310,6 +301,13 @@ class Manager: 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):