From 4933618f500588f09f18e12f8c270b40a3e34769 Mon Sep 17 00:00:00 2001 From: Andrew Resch Date: Fri, 28 Nov 2008 23:36:18 +0000 Subject: [PATCH] Fix #47 the state and config files are no longer invalidated when there is no diskspace --- deluge/core/torrentmanager.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/deluge/core/torrentmanager.py b/deluge/core/torrentmanager.py index 2785d9a71..318fc7098 100644 --- a/deluge/core/torrentmanager.py +++ b/deluge/core/torrentmanager.py @@ -29,6 +29,7 @@ import cPickle import os.path import os import time +import shutil import gobject @@ -531,12 +532,22 @@ class TorrentManager(component.Component): try: log.debug("Saving torrent state file.") state_file = open( - os.path.join(self.config["state_location"], "torrents.state"), + os.path.join(self.config["state_location"], "torrents.state.new"), "wb") cPickle.dump(state, state_file) state_file.close() except IOError: log.warning("Unable to save state file.") + return True + + # We have to move the 'torrents.state.new' file to 'torrents.state' + try: + shutil.move( + os.path.join(self.config["state_location"], "torrents.state.new"), + os.path.join(self.config["state_location"], "torrents.state")) + except IOError: + log.warning("Unable to save state file.") + return True # We return True so that the timer thread will continue return True