incubator-tashi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strou...@apache.org
Subject svn commit: r1292654 - /incubator/tashi/branches/stroucki-irpbugs/src/tashi/clustermanager/data/pickled.py
Date Thu, 23 Feb 2012 05:36:34 GMT
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)):



Mime
View raw message