Include uploaded_memory in pickle_state().

This commit is contained in:
Alex Dedul 2007-08-10 03:18:25 +00:00
parent cc20a34906
commit b7c3fddf0e

View File

@ -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"