owners_cache: implicitly add parent directories
authorZac Medico <zmedico@gentoo.org>
Tue, 1 Mar 2011 18:06:01 +0000 (10:06 -0800)
committerZac Medico <zmedico@gentoo.org>
Tue, 1 Mar 2011 18:06:01 +0000 (10:06 -0800)
We can't necessarily assume that they are explicitly listed in
CONTENTS.

pym/portage/dbapi/vartree.py

index 2e97fdbee34c3daed16833c28714cdf48cc451da..2e5d87379428ecbbaa36aca79d56af9ed939f7c9 100644 (file)
@@ -823,8 +823,25 @@ class vardbapi(dbapi):
                        if not contents:
                                # Empty path is a code used to represent empty contents.
                                self._add_path("", pkg_hash)
+
+                       # When adding paths, implicitly add parent directories,
+                       # since we can't necessarily assume that they are
+                       # explicitly listed in CONTENTS.
+                       added_paths = set()
                        for x in contents:
-                               self._add_path(x[root_len:], pkg_hash)
+                               x = x[root_len:]
+                               added_paths.add(x)
+                               self._add_path(x, pkg_hash)
+                               x_split = x.split(os.sep)
+                               x_split.pop()
+                               while x_split:
+                                       parent = os.sep.join(x_split)
+                                       if parent in added_paths:
+                                               break
+                                       added_paths.add(parent)
+                                       self._add_path(parent, pkg_hash)
+                                       x_split.pop()
+
                        self._vardb._aux_cache["modified"].add(cpv)
 
                def _add_path(self, path, pkg_hash):