diff options
author | Zac Medico <zmedico@gentoo.org> | 2008-05-24 20:35:30 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2008-05-24 20:35:30 +0000 |
commit | 522b31e2198a5c4a717b38273b61cc8ff3d98dfb (patch) | |
tree | 9abcb2e38630988a6e46a68e7df201e2ed60acaf | |
parent | 87ac46d189a042961e8c9c53301657f81a593aac (diff) | |
download | portage-522b31e2198a5c4a717b38273b61cc8ff3d98dfb.tar.gz portage-522b31e2198a5c4a717b38273b61cc8ff3d98dfb.tar.bz2 portage-522b31e2198a5c4a717b38273b61cc8ff3d98dfb.zip |
Bug #223417 - Make the vardbapi.cpv_all() use_cache parameter useful
for forcing direct os.listdir() calls. This is more of an issue now
that these listdir() calls are frequently triggered when merging
packages (due to things like blocker and preserve-libs handling).
svn path=/main/trunk/; revision=10390
-rw-r--r-- | pym/_emerge/__init__.py | 2 | ||||
-rw-r--r-- | pym/portage/dbapi/vartree.py | 19 |
2 files changed, 19 insertions, 2 deletions
diff --git a/pym/_emerge/__init__.py b/pym/_emerge/__init__.py index 0a5306bf6..c9ab97722 100644 --- a/pym/_emerge/__init__.py +++ b/pym/_emerge/__init__.py @@ -998,7 +998,7 @@ class FakeVartree(portage.vartree): vdb_lock = portage.locks.lockdir(vdb_path) real_dbapi = real_vartree.dbapi slot_counters = {} - for cpv in real_dbapi.cpv_all(): + for cpv in real_dbapi.cpv_all(use_cache=0): cache_key = ("installed", self.root, cpv, "nomerge") pkg = self._pkg_cache.get(cache_key) if pkg is not None: diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py index a5d73843a..69b1512ef 100644 --- a/pym/portage/dbapi/vartree.py +++ b/pym/portage/dbapi/vartree.py @@ -136,7 +136,7 @@ class LinkageMap(object): libs = {} obj_properties = {} lines = [] - for cpv in self._dbapi.cpv_all(): + for cpv in self._dbapi.cpv_all(use_cache=0): lines += self._dbapi.aux_get(cpv, ["NEEDED.ELF.2"])[0].split('\n') # Cache NEEDED.* files avoid doing excessive IO for every rebuild. self._dbapi.flush_cache() @@ -455,8 +455,25 @@ class vardbapi(dbapi): return returnme def cpv_all(self, use_cache=1): + """ + Set use_cache=0 to bypass the portage.cachedir() cache in cases + when the accuracy of mtime staleness checks should not be trusted + (generally this is only necessary in critical sections that + involve merge or unmerge of packages). + """ returnme = [] basepath = os.path.join(self.root, VDB_PATH) + os.path.sep + + if use_cache: + from portage import listdir + else: + def listdir(p, **kwargs): + try: + return [x for x in os.listdir(p) \ + if os.path.isdir(os.path.join(p, x))] + except EnvironmentError: + return [] + for x in listdir(basepath, EmptyOnError=1, ignorecvs=1, dirsonly=1): if self._excluded_dirs.match(x) is not None: continue |