use atomic_ofstream for mtimedb commits
authorZac Medico <zmedico@gentoo.org>
Thu, 9 Feb 2006 01:38:34 +0000 (01:38 -0000)
committerZac Medico <zmedico@gentoo.org>
Thu, 9 Feb 2006 01:38:34 +0000 (01:38 -0000)
svn path=/main/trunk/; revision=2682

pym/portage.py

index 14992901fd643e6284a8b3bd22ac50fc494491cc..339cd2e429caf1cfdfa1b2860f1debff76aab23a 100644 (file)
@@ -6878,13 +6878,17 @@ def commit_mtimedb():
        if mtimedb:
        # Store mtimedb
                mymfn=mtimedbfile
+               f = None
                try:
                        mtimedb["version"]=VERSION
-                       cPickle.dump(mtimedb, open(mymfn,"w"), -1)
+                       f = portage_util.atomic_ofstream(mymfn)
+                       cPickle.dump(mtimedb, f, -1)
+                       f.close()
                except SystemExit, e:
                        raise
                except Exception, e:
-                       pass
+                       if f is not None:
+                               f.abort()
 
                try:
                        os.chown(mymfn,uid,portage_gid)