Add some sanity checks and error tolerance in the owners cache. v2.2_pre8
authorZac Medico <zmedico@gentoo.org>
Tue, 10 Jun 2008 03:31:30 +0000 (03:31 -0000)
committerZac Medico <zmedico@gentoo.org>
Tue, 10 Jun 2008 03:31:30 +0000 (03:31 -0000)
svn path=/main/trunk/; revision=10633

pym/portage/dbapi/vartree.py

index 4c67dfa05dacb7168da4efa46a08f85d986323ca..190157b886aa65b5dd512be1e2e6d16a6ca35c88 100644 (file)
@@ -619,6 +619,8 @@ class vardbapi(dbapi):
                                owners = None
                        elif "base_names" not in owners:
                                owners = None
+                       elif not isinstance(owners["base_names"], dict):
+                               owners = None
 
                if owners is None:
                        owners = {
@@ -994,8 +996,20 @@ class vardbapi(dbapi):
                                pkgs = base_names.get(name_hash)
                                if pkgs is not None:
                                        for hash_value in pkgs:
+                                               try:
+                                                       if len(hash_value) != 3:
+                                                               continue
+                                               except TypeError:
+                                                       continue
                                                cpv, counter, mtime = hash_value
-                                               if hash_pkg(cpv) != hash_value:
+                                               if not isinstance(cpv, basestring):
+                                                       continue
+                                               try:
+                                                       current_hash = hash_pkg(cpv)
+                                               except KeyError:
+                                                       continue
+
+                                               if current_hash != hash_value:
                                                        continue
                                                if dblink(cpv).isowner(path, root):
                                                        yield dblink(cpv), path