diff options
author | Zac Medico <zmedico@gentoo.org> | 2006-04-29 08:04:30 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2006-04-29 08:04:30 +0000 |
commit | 627993585f55e0c2f6bd30664e1e4fe21c66549e (patch) | |
tree | 69a15d8fcbf96a9f343044a91dbcd1cf0d3f8ce6 | |
parent | 4f91608e8dd1f4f01cbf092c833018d1e2c2527a (diff) | |
download | portage-627993585f55e0c2f6bd30664e1e4fe21c66549e.tar.gz portage-627993585f55e0c2f6bd30664e1e4fe21c66549e.tar.bz2 portage-627993585f55e0c2f6bd30664e1e4fe21c66549e.zip |
Enable portage.commit_mtimedb() to work without globals.
svn path=/main/trunk/; revision=3268
-rw-r--r-- | pym/portage.py | 39 |
1 files changed, 15 insertions, 24 deletions
diff --git a/pym/portage.py b/pym/portage.py index f3e4ea1ed..4df390067 100644 --- a/pym/portage.py +++ b/pym/portage.py @@ -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 |