Bug #223417 - Make the vardbapi.cpv_all() use_cache parameter useful
authorZac Medico <zmedico@gentoo.org>
Sun, 25 May 2008 04:15:50 +0000 (04:15 -0000)
committerZac Medico <zmedico@gentoo.org>
Sun, 25 May 2008 04:15:50 +0000 (04:15 -0000)
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).
(trunk r10390)

svn path=/main/branches/2.1.2/; revision=10406

bin/emerge
pym/portage.py

index dafb3bb66864bf131c9f21fa9003904bd658b1c5..47c095e8983ef124e875be2f8e63e9f3e52e652b 100755 (executable)
@@ -1163,7 +1163,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:
index 85b9bf670241b7a97258cd0300eb323d70793b7f..cf38107dfc24ab3516b3421f5c86b881a93e84f1 100644 (file)
@@ -6764,8 +6764,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