]> code.delx.au - pymsnt/blobdiff - src/xdb.py
Reordering of switchboard timeouts.
[pymsnt] / src / xdb.py
index 225e892b33403d76d58a7b4e8b9f12e3d3c5c646..1e3e33e64c91a3a93f3a454a52a75809a998b674 100644 (file)
@@ -5,8 +5,8 @@ from tlib import xmlw
 from debug import LogEvent, INFO, WARN
 import os
 import os.path
+import shutil
 import config
-import legacy
 
 X = os.path.sep
 SPOOL_UMASK = 0077
@@ -54,9 +54,14 @@ class XDB:
                pre = self.name + X + hash + X
                if not os.path.exists(pre):
                        os.makedirs(pre)
-               f = open(pre + file + ".xml", "w")
-               f.write(text)
-               f.close()
+               try:
+                       f = open(pre + file + ".xml.new", "w")
+                       f.write(text)
+                       f.close()
+                       shutil.move(pre + file + ".xml.new", pre + file + ".xml")
+               except IOError, e:
+                       LogEvent(WARN, "", "IOError " + str(e))
+                       raise
                os.umask(prev_umask)
        
        def files(self):