You are viewing a plain text version of this content. The canonical link for it is here.
Posted to tashi-commits@incubator.apache.org by st...@apache.org on 2012/02/23 05:36:34 UTC

svn commit: r1292654 - /incubator/tashi/branches/stroucki-irpbugs/src/tashi/clustermanager/data/pickled.py

Author: stroucki
Date: Thu Feb 23 05:36:34 2012
New Revision: 1292654

URL: http://svn.apache.org/viewvc?rev=1292654&view=rev
Log:
picked: don't overwrite database file; write to temp file and replace atomically

Modified:
    incubator/tashi/branches/stroucki-irpbugs/src/tashi/clustermanager/data/pickled.py

Modified: incubator/tashi/branches/stroucki-irpbugs/src/tashi/clustermanager/data/pickled.py
URL: http://svn.apache.org/viewvc/incubator/tashi/branches/stroucki-irpbugs/src/tashi/clustermanager/data/pickled.py?rev=1292654&r1=1292653&r2=1292654&view=diff
==============================================================================
--- incubator/tashi/branches/stroucki-irpbugs/src/tashi/clustermanager/data/pickled.py (original)
+++ incubator/tashi/branches/stroucki-irpbugs/src/tashi/clustermanager/data/pickled.py Thu Feb 23 05:36:34 2012
@@ -52,9 +52,13 @@ class Pickled(FromConfig):
 		return ch
 	
 	def save(self):
-		file = open(self.file, "w")
+		filename = self.file
+		tempfile = ".%s" % filename
+
+		file = open(tempfile, "w")
 		cPickle.dump((self.cleanHosts(), self.cleanInstances(), self.networks, self.users), file)
 		file.close()
+		os.rename(tempfile, filename)
 
 	def load(self):
 		if (os.access(self.file, os.F_OK)):