Enable portage.commit_mtimedb() to work without globals.
authorZac Medico <zmedico@gentoo.org>
Sat, 29 Apr 2006 08:04:30 +0000 (08:04 -0000)
committerZac Medico <zmedico@gentoo.org>
Sat, 29 Apr 2006 08:04:30 +0000 (08:04 -0000)
svn path=/main/trunk/; revision=3268

pym/portage.py

index f3e4ea1ed46bc02a6957c209270b5079951c5634..4df39006769428cd73d89a97a1652a988b1eff94 100644 (file)
@@ -6600,30 +6600,21 @@ def parse_updates(mycontent):
                myupd.append(mysplit)
        return myupd, errors
 
-def commit_mtimedb():
-       global mtimedb
-       if mtimedb:
-       # Store mtimedb
-               mymfn=mtimedbfile
-               f = None
-               try:
-                       mtimedb["version"]=VERSION
-                       f = atomic_ofstream(mymfn)
-                       cPickle.dump(mtimedb, f, -1)
-                       f.close()
-               except SystemExit, e:
-                       raise
-               except Exception, e:
-                       if f is not None:
-                               f.abort()
-
-               try:
-                       os.chown(mymfn,uid,portage_gid)
-                       os.chmod(mymfn,0664)
-               except SystemExit, e:
-                       raise
-               except Exception, e:
-                       pass
+def commit_mtimedb(mydict=None, filename=None):
+       if mydict is None:
+               global mtimedb
+               mydict = mtimedb
+       if filename is None:
+               global mtimedbfile
+               filename = mtimedbfile
+       mydict["version"] = VERSION
+       try:
+               f = atomic_ofstream(filename)
+               cPickle.dump(mydict, f, -1)
+               f.close()
+               portage_util.apply_secpass_permissions(filename, uid=uid, gid=portage_gid, mode=0664)
+       except (IOError, OSError), e:
+               pass
 
 def portageexit():
        global uid,portage_gid,portdb,db