Factor out mtimedb saving code from portageexit() into a new commit_mtimedb
authorJason Stubbs <jstubbs@gentoo.org>
Sun, 25 Dec 2005 08:04:56 +0000 (08:04 -0000)
committerJason Stubbs <jstubbs@gentoo.org>
Sun, 25 Dec 2005 08:04:56 +0000 (08:04 -0000)
function and call that rather than portageexit() after package updates.

svn path=/main/trunk/; revision=2455

pym/portage.py

index 0b8623796d53b66416030bf9ec70148a83ab2c75..ab665ce641e1420405c08eeab10821559b1f4817 100644 (file)
@@ -6830,29 +6830,31 @@ def do_upgrade(mykey):
        myworld.close()
        print ""
 
+def commit_mtimedb():
+       if mtimedb:
+       # Store mtimedb
+               mymfn=mtimedbfile
+               try:
+                       mtimedb["version"]=VERSION
+                       cPickle.dump(mtimedb, open(mymfn,"w"), -1)
+               except SystemExit, e:
+                       raise
+               except Exception, e:
+                       pass
+
+               try:
+                       os.chown(mymfn,uid,portage_gid)
+                       os.chmod(mymfn,0664)
+               except SystemExit, e:
+                       raise
+               except Exception, e:
+                       pass
+
 def portageexit():
        global uid,portage_gid,portdb,db
        if secpass and not os.environ.has_key("SANDBOX_ACTIVE"):
                close_portdbapi_caches()
-
-               if mtimedb:
-               # Store mtimedb
-                       mymfn=mtimedbfile
-                       try:
-                               mtimedb["version"]=VERSION
-                               cPickle.dump(mtimedb, open(mymfn,"w"), -1)
-                       except SystemExit, e:
-                               raise
-                       except Exception, e:
-                               pass
-
-                       try:
-                               os.chown(mymfn,uid,portage_gid)
-                               os.chmod(mymfn,0664)
-                       except SystemExit, e:
-                               raise
-                       except Exception, e:
-                               pass
+               commit_mtimedb()
 
 atexit.register(portageexit)
 
@@ -6878,7 +6880,7 @@ if (secpass==2) and (not os.environ.has_key("SANDBOX_ACTIVE")):
                                         (settings["PORTAGE_CALLER"] == "fixpackages"):
                                        didupdate=1
                                        do_upgrade(mykey)
-                                       portageexit() # This lets us save state for C-c.
+                                       commit_mtimedb() # This lets us save state for C-c.
                except OSError:
                        #directory doesn't exist
                        pass