use new write_atomic() function for all world file updates
authorZac Medico <zmedico@gentoo.org>
Thu, 9 Feb 2006 01:10:08 +0000 (01:10 -0000)
committerZac Medico <zmedico@gentoo.org>
Thu, 9 Feb 2006 01:10:08 +0000 (01:10 -0000)
svn path=/main/trunk/; revision=2681

bin/emaint
bin/emerge
bin/regenworld
pym/portage.py

index 6f9977dee685c3a4f0886e0625bc7025bba2b3f7..e6d11fc1595728c2d71325e7ddc95990a7234097 100755 (executable)
@@ -40,7 +40,7 @@ class WorldHandler(object):
        def fix(self):
                errors = []
                try:
-                       open(portage_const.WORLD_FILE, "w").write("\n".join(self.okay))
+                       portage.write_atomic(portage_const.WORLD_FILE,"\n".join(self.okay))
                except OSError:
                        errors.append(portage_const.WORLD_FILE + " could not be opened for writing")
                return errors
index 716068a243e8261dbca884c3f707c34864cb071d..795092e34fcf6ba6ceba8641e3235ee9f644254b 100755 (executable)
@@ -1916,7 +1916,7 @@ class depgraph:
                                                        myfavdict[myfavkey]=myfavkey
                                                        print ">>> Recording",myfavkey,"in \"world\" favorites file..."
                        if not "--fetchonly" in myopts:
-                               portage.writedict(myfavdict,portage.root+portage.WORLD_FILE,writekey=0)
+                               portage.write_atomic(os.path.join(portage.root,portage.WORLD_FILE),"\n".join(myfavdict.values()))
 
                        portage.mtimedb["resume"]["mergelist"]=mymergelist[:]
 
@@ -2087,7 +2087,7 @@ class depgraph:
                                                myfavdict[myfavkey]=myfavkey
                                                print ">>> Recording",myfavkey,"in \"world\" favorites file..."
                                                emergelog(" === ("+str(mergecount)+" of "+str(len(mymergelist))+") Updating world file ("+x[pkgindex]+")")
-                                               portage.writedict(myfavdict,myroot+portage.WORLD_FILE,writekey=0)
+                                               portage.write_atomic(os.path.join(myroot,portage.WORLD_FILE),"\n".join(myfavdict.values()))
 
                                if ("noclean" not in portage.features) and (x[0] != "binary"):
                                        short_msg = "emerge: ("+str(mergecount)+" of "+str(len(mymergelist))+") "+x[pkgindex]+" Clean Post"
index 14ec51d5c3de0180dd684dc593c9503627f242b8..8723d7f203d98c5187320e41389ae69b2d74ba0c 100755 (executable)
@@ -88,6 +88,4 @@ for mykey in biglist:
                        print "add to world:",myfavkey
                        worldlist.append(myfavkey)
 
-myfile=open(portage.WORLD_FILE, "w")
-myfile.write(string.join(worldlist, '\n')+'\n')
-myfile.close()
+portage.write_atomic(portage.WORLD_FILE,"\n".join(worldlist))
index 0018ab9145bbcb09a4b0e8b10d1cc186022bf26a..14992901fd643e6284a8b3bd22ac50fc494491cc 100644 (file)
@@ -92,7 +92,7 @@ try:
                                 portage_uid, portage_gid
 
        import portage_util
-       from portage_util import grabdict, grabdict_package, grabfile, grabfile_package, \
+       from portage_util import grabdict, grabdict_package, grabfile, grabfile_package, write_atomic, \
                map_dictlist_vals, pickle_read, pickle_write, stack_dictlist, stack_dicts, stack_lists, \
                unique_array, varexpand, writedict, writemsg, writemsg_stdout, getconfig, dump_traceback
        import portage_exception
@@ -5862,10 +5862,7 @@ class dblink:
                                os.chown(pdir, 0, portage_gid)
                                os.chmod(pdir, 02770)
 
-                       myworld=open(self.myroot+WORLD_FILE,"w")
-                       for x in newworldlist:
-                               myworld.write(x+"\n")
-                       myworld.close()
+                       write_atomic(os.path.join(self.myroot,WORLD_FILE),"\n".join(newworldlist))
 
                #do original postrm
                if myebuildpath and os.path.exists(myebuildpath):
@@ -6874,10 +6871,7 @@ def do_upgrade(mykey):
        if processed:
                #update our internal mtime since we processed all our directives.
                mtimedb["updates"][mykey]=os.stat(mykey)[stat.ST_MTIME]
-       myworld=open("/"+WORLD_FILE,"w")
-       for x in worldlist:
-               myworld.write(x+"\n")
-       myworld.close()
+       write_atomic(WORLD_FILE,"\n".join(worldlist))
        print ""
 
 def commit_mtimedb():