diff --git a/src/core.py b/src/core.py index 2d03460be..53a2a0e39 100644 --- a/src/core.py +++ b/src/core.py @@ -327,10 +327,6 @@ class Manager: pass def quit(self): - # save upload memory - print "Saving uploaded memory..." - self.save_upmem() - # Pickle the state self.pickle_state() @@ -362,17 +358,7 @@ class Manager: os.popen4('taskkill.exe /IM dbus-daemon-deluge.exe /F') def pickle_state(self): - # Pickle the state so if we experience a crash, the latest state is - # available - print "Pickling state..." - if not os.path.exists(self.base_dir): - os.makedirs(self.base_dir) - output = open(os.path.join(self.base_dir, STATE_FILENAME), 'wb') - pickle.dump(self.state, output) - output.close() - - def save_upmem(self): - # Save the uploaded data from this session to the existing upload memory + print "save uploaded memory" for unique_ID in self.unique_IDs.keys(): # self.get_core_torrent_state purposefully not cached. try: @@ -381,7 +367,14 @@ class Manager: self.get_core_torrent_state(unique_ID, False)['total_upload'] except AttributeError: self.unique_IDs[unique_ID].initial_uploaded_memory = 0 - return True + # Pickle the state so if we experience a crash, the latest state is + # available + print "Pickling state..." + if not os.path.exists(self.base_dir): + os.makedirs(self.base_dir) + output = open(os.path.join(self.base_dir, STATE_FILENAME), 'wb') + pickle.dump(self.state, output) + output.close() # Preference management functions diff --git a/src/interface.py b/src/interface.py index 24584a204..09de7fbdb 100644 --- a/src/interface.py +++ b/src/interface.py @@ -784,7 +784,7 @@ window, please enter your password")) trackers_changed = self.manager.unique_IDs[uid].trackers_changed except AttributeError: trackers_changed = 0 - self.manager.save_upmem() + self.manager.pickle_state() uploaded_memory = self.manager.unique_IDs[uid].uploaded_memory priorities = self.manager.get_priorities(uid) save_info = [path, save_dir, order, trackerslist, \ @@ -808,7 +808,7 @@ window, please enter your password")) if save_info[4]: self.manager.unique_IDs[unique_ID].initial_uploaded_memory = \ save_info[4] - self.manager.save_upmem() + self.manager.pickle_state() if save_info[6]: try: self.manager.replace_trackers(unique_ID, save_info[3]) @@ -1042,7 +1042,7 @@ window, please enter your password")) # focus on startup self.update() gobject.timeout_add(int(1000*self.manager.config.get("gui_update_interval")), self.update) - gobject.timeout_add(60000, self.manager.save_upmem) + gobject.timeout_add(250000, self.manager.pickle_state) gobject.timeout_add(300000, self.manager.save_fastresume_data) # Load plugins after we showed main window (if not started in tray)