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