1 |
On Thu, 12 Jul 2018 21:09:46 -0700 |
2 |
Zac Medico <zmedico@g.o> wrote: |
3 |
|
4 |
> When removal of a symlink is triggered by removal of the directory |
5 |
> that it points to, revisit the parent directories of the symlink. |
6 |
> |
7 |
> Bug: https://bugs.gentoo.org/640058 |
8 |
> --- |
9 |
> pym/portage/dbapi/vartree.py | 23 +++++++++++++++++++++-- |
10 |
> 1 file changed, 21 insertions(+), 2 deletions(-) |
11 |
> |
12 |
> diff --git a/pym/portage/dbapi/vartree.py |
13 |
> b/pym/portage/dbapi/vartree.py index 1a86940f1..43e3c4f1a 100644 |
14 |
> --- a/pym/portage/dbapi/vartree.py |
15 |
> +++ b/pym/portage/dbapi/vartree.py |
16 |
> @@ -2753,9 +2753,13 @@ class dblink(object): |
17 |
> real_root = self.settings['ROOT'] |
18 |
> |
19 |
> dirs = sorted(dirs) |
20 |
> - dirs.reverse() |
21 |
> + revisit = {} |
22 |
> |
23 |
> - for obj, inode_key in dirs: |
24 |
> + while True: |
25 |
> + try: |
26 |
> + obj, inode_key = dirs.pop() |
27 |
> + except IndexError: |
28 |
> + break |
29 |
> # Treat any directory named "info" as a |
30 |
> candidate here, # since it might have been in INFOPATH previously even |
31 |
> # though it may not be there now. |
32 |
> @@ -2818,6 +2822,7 @@ class dblink(object): |
33 |
> raise |
34 |
> if e.errno != errno.ENOENT: |
35 |
> show_unmerge("---", |
36 |
> unmerge_desc["!empty"], "dir", obj) |
37 |
> + revisit[obj] = inode_key |
38 |
> |
39 |
> # Since we didn't remove this |
40 |
> directory, record the directory # itself for use in syncfs calls, if |
41 |
> we have removed another @@ -2838,6 +2843,7 @@ class dblink(object): |
42 |
> # no need to protect symlinks that |
43 |
> point to it. unmerge_syms = protected_symlinks.pop(inode_key, None) |
44 |
> if unmerge_syms is not None: |
45 |
> + parents = [] |
46 |
> for relative_path in |
47 |
> unmerge_syms: obj = os.path.join(real_root, |
48 |
> relative_path.lstrip(os.sep)) |
49 |
> @@ -2849,6 +2855,19 @@ class dblink(object): |
50 |
> raise |
51 |
> del e |
52 |
> show_unmerge("!!!", |
53 |
> "", "sym", obj) |
54 |
> + else: |
55 |
> + |
56 |
> parents.append(os.path.dirname(obj)) + |
57 |
> + if parents: |
58 |
> + # Revisit parents |
59 |
> recursively (bug 640058). |
60 |
> + recursive_parents = |
61 |
> [] |
62 |
> + for parent in |
63 |
> set(parents): |
64 |
> + while parent |
65 |
> in revisit: |
66 |
> + |
67 |
> recursive_parents.append(parent) |
68 |
> + |
69 |
> parent = os.path.dirname(parent) + |
70 |
> + for parent in |
71 |
> sorted(set(recursive_parents)): |
72 |
> + |
73 |
> dirs.append((parent, revisit.pop(parent))) |
74 |
> def isowner(self, filename, destroot=None): |
75 |
> """ |
76 |
|
77 |
LGTM |
78 |
|
79 |
-- |
80 |
Brian Dolbec <dolsen> |