1 |
-----BEGIN PGP SIGNED MESSAGE----- |
2 |
Hash: SHA512 |
3 |
|
4 |
On 06/11/15 08:44, Zac Medico wrote: |
5 |
> Fix flaws in logic involving the updatecache_flg variable. Use this |
6 |
> variable to skip hooks and metadata-transfer when sync fails (or the |
7 |
> server timestamp has not changed). |
8 |
> |
9 |
> X-Gentoo-Bug: 564988 |
10 |
> X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=564988 |
11 |
> --- |
12 |
> pym/portage/emaint/modules/sync/sync.py | 15 ++++++++++----- |
13 |
> pym/portage/sync/controller.py | 3 ++- |
14 |
> pym/portage/sync/modules/rsync/rsync.py | 17 ++++++++++------- |
15 |
> 3 files changed, 22 insertions(+), 13 deletions(-) |
16 |
> |
17 |
> diff --git a/pym/portage/emaint/modules/sync/sync.py b/pym/portage/emaint/modules/sync/sync.py |
18 |
> index 57c779d..faa20d9 100644 |
19 |
> --- a/pym/portage/emaint/modules/sync/sync.py |
20 |
> +++ b/pym/portage/emaint/modules/sync/sync.py |
21 |
> @@ -232,16 +232,19 @@ class SyncRepos(object): |
22 |
> sync_scheduler.wait() |
23 |
> retvals = sync_scheduler.retvals |
24 |
> msgs.extend(sync_scheduler.msgs) |
25 |
> + updatecache_flg = sync_scheduler.updatecache_flg |
26 |
> |
27 |
> - # run the post_sync_hook one last time for |
28 |
> - # run only at sync completion hooks |
29 |
> - rcode = sync_manager.perform_post_sync_hook('') |
30 |
> if retvals: |
31 |
> msgs.extend(self.rmessage(retvals, 'sync')) |
32 |
> else: |
33 |
> msgs.extend(self.rmessage([('None', os.EX_OK)], 'sync')) |
34 |
> - if rcode: |
35 |
> - msgs.extend(self.rmessage([('None', rcode)], 'post-sync')) |
36 |
> + |
37 |
> + if updatecache_flg: |
38 |
> + # run the post_sync_hook one last time for |
39 |
> + # run only at sync completion hooks |
40 |
> + rcode = sync_manager.perform_post_sync_hook('') |
41 |
> + if rcode: |
42 |
> + msgs.extend(self.rmessage([('None', rcode)], 'post-sync')) |
43 |
> |
44 |
> # Reload the whole config. |
45 |
> portage._sync_mode = False |
46 |
> @@ -321,6 +324,7 @@ class SyncScheduler(AsyncScheduler): |
47 |
> self._init_graph() |
48 |
> self.retvals = [] |
49 |
> self.msgs = [] |
50 |
> + self.updatecache_flg = False |
51 |
> |
52 |
> def _init_graph(self): |
53 |
> ''' |
54 |
> @@ -350,6 +354,7 @@ class SyncScheduler(AsyncScheduler): |
55 |
> returncode = task.returncode |
56 |
> if task.returncode == os.EX_OK: |
57 |
> returncode, message, updatecache_flg = task.result |
58 |
> + self.updatecache_flg |= updatecache_flg |
59 |
> if message: |
60 |
> self.msgs.append(message) |
61 |
> repo = task.kwargs['repo'].name |
62 |
> diff --git a/pym/portage/sync/controller.py b/pym/portage/sync/controller.py |
63 |
> index e8132c2..1beb545 100644 |
64 |
> --- a/pym/portage/sync/controller.py |
65 |
> +++ b/pym/portage/sync/controller.py |
66 |
> @@ -156,7 +156,8 @@ class SyncManager(object): |
67 |
> taskmaster = TaskHandler(callback=self.do_callback) |
68 |
> taskmaster.run_tasks(tasks, func, status, options=task_opts) |
69 |
> |
70 |
> - self.perform_post_sync_hook(repo.name, repo.sync_uri, repo.location) |
71 |
> + if self.updatecache_flg: |
72 |
> + self.perform_post_sync_hook(repo.name, repo.sync_uri, repo.location) |
73 |
> |
74 |
> return self.exitcode, None, self.updatecache_flg |
75 |
> |
76 |
> diff --git a/pym/portage/sync/modules/rsync/rsync.py b/pym/portage/sync/modules/rsync/rsync.py |
77 |
> index 8ae8a5c..e0f76b3 100644 |
78 |
> --- a/pym/portage/sync/modules/rsync/rsync.py |
79 |
> +++ b/pym/portage/sync/modules/rsync/rsync.py |
80 |
> @@ -112,10 +112,10 @@ class RsyncSync(NewBase): |
81 |
> if syncuri.startswith("file://"): |
82 |
> self.proto = "file" |
83 |
> dosyncuri = syncuri[6:] |
84 |
> - is_synced, exitcode = self._do_rsync( |
85 |
> + is_synced, exitcode, updatecache_flg = self._do_rsync( |
86 |
> dosyncuri, timestamp, opts) |
87 |
> self._process_exitcode(exitcode, dosyncuri, out, 1) |
88 |
> - return (exitcode, exitcode == os.EX_OK) |
89 |
> + return (exitcode, updatecache_flg) |
90 |
> |
91 |
> retries=0 |
92 |
> try: |
93 |
> @@ -138,7 +138,7 @@ class RsyncSync(NewBase): |
94 |
> else: |
95 |
> # getaddrinfo needs the brackets stripped |
96 |
> getaddrinfo_host = hostname[1:-1] |
97 |
> - updatecache_flg=True |
98 |
> + updatecache_flg = False |
99 |
> all_rsync_opts = set(self.rsync_opts) |
100 |
> all_rsync_opts.update(self.extra_rsync_opts) |
101 |
> |
102 |
> @@ -240,7 +240,8 @@ class RsyncSync(NewBase): |
103 |
> if dosyncuri.startswith('ssh://'): |
104 |
> dosyncuri = dosyncuri[6:].replace('/', ':/', 1) |
105 |
> |
106 |
> - is_synced, exitcode = self._do_rsync(dosyncuri, timestamp, opts) |
107 |
> + is_synced, exitcode, updatecache_flg = self._do_rsync( |
108 |
> + dosyncuri, timestamp, opts) |
109 |
> if is_synced: |
110 |
> break |
111 |
> |
112 |
> @@ -251,7 +252,6 @@ class RsyncSync(NewBase): |
113 |
> else: |
114 |
> # over retries |
115 |
> # exit loop |
116 |
> - updatecache_flg=False |
117 |
> exitcode = EXCEEDED_MAX_RETRIES |
118 |
> break |
119 |
> self._process_exitcode(exitcode, dosyncuri, out, maxretries) |
120 |
> @@ -382,6 +382,7 @@ class RsyncSync(NewBase): |
121 |
> |
122 |
> |
123 |
> def _do_rsync(self, syncuri, timestamp, opts): |
124 |
> + updatecache_flg = False |
125 |
> is_synced = False |
126 |
> if timestamp != 0 and "--quiet" not in opts: |
127 |
> print(">>> Checking server timestamp ...") |
128 |
> @@ -489,7 +490,7 @@ class RsyncSync(NewBase): |
129 |
> print(">>> In order to force sync, remove '%s'." % self.servertimestampfile) |
130 |
> print(">>>") |
131 |
> print() |
132 |
> - return is_synced, exitcode |
133 |
> + return is_synced, exitcode, updatecache_flg |
134 |
> elif (servertimestamp != 0) and (servertimestamp < timestamp): |
135 |
> self.logger(self.xterm_titles, |
136 |
> ">>> Server out of date: %s" % syncuri) |
137 |
> @@ -543,6 +544,8 @@ class RsyncSync(NewBase): |
138 |
> os.unlink(self.servertimestampfile) |
139 |
> except OSError: |
140 |
> pass |
141 |
> + else: |
142 |
> + updatecache_flg = True |
143 |
> |
144 |
> if exitcode in [0,1,3,4,11,14,20,21]: |
145 |
> is_synced = True |
146 |
> @@ -554,4 +557,4 @@ class RsyncSync(NewBase): |
147 |
> # --prune-empty-directories. Retry for a server that supports |
148 |
> # at least rsync protocol version 29 (>=rsync-2.6.4). |
149 |
> pass |
150 |
> - return is_synced, exitcode |
151 |
> + return is_synced, exitcode, updatecache_flg |
152 |
> |
153 |
I know nothing about the egencache stuff. Maybe Michał can comment? |
154 |
|
155 |
- -- |
156 |
Alexander |
157 |
bernalex@g.o |
158 |
https://secure.plaimi.net/~alexander |
159 |
-----BEGIN PGP SIGNATURE----- |
160 |
Version: GnuPG v2 |
161 |
|
162 |
iQIcBAEBCgAGBQJWPFvCAAoJENQqWdRUGk8Bv9IP/2SZHOXOycQkX46/cJT9ELr/ |
163 |
3yofUPa9fwwUFYOaM/QaTTKdAbJBy9UnTbGl3ho500p9xzB5uUq2+8OZQ9f9Nsdn |
164 |
8hKDDdm0LGUCnGW+QmzsT0Mqa0fRaG9WUTF4ysUQ818mLeq02MedjLzxDOibyz4/ |
165 |
B+ExdkyhiQs9x0pfIQl7IezMvS5qZYwtMqTlX4Vk1dOENPHTSpkCfiAU576qfZK7 |
166 |
GKxaDQ9zI8cN2Twjl588JU9e5feA+/SOaMCcESFIp5Q4/rh0vDcKr3CQfcjJEVkO |
167 |
keOVT87+evVAwc1bCXqE30Q+ezbYmrXvFN95bkxqw55jmWJA4daywx29p8S2NWHF |
168 |
qO5etd3KEkaskbBlsvr3i47YRX7raFVtuIlxTAcsJi801fCTqq+iC32Ex1BY6hdW |
169 |
HDUjrZBjWljhsAxhrVE9H6QnBKg344rpj9ELMiJeD+T173lfqxYiRRe+LQJdCN4K |
170 |
olReMMmWzCILqq+mW+BOKn749q8rXAsa4bPv0tIGb0WZ7AgGdd2bOxQF0T3fhshJ |
171 |
eO0yzn/vsfSE4KmjbKoqzqwksVh9UOhY1p7j0QO9RZEfgNNiwJcAotQ4yPRHtdxh |
172 |
NtYfZBsrFcVFn2PY87hr38mxxb21RX7ls6SD816b6aYh1Tc0NvX+kJyf98xzchd/ |
173 |
4sHH3ibM9UwBVRbT4ItL |
174 |
=BMQo |
175 |
-----END PGP SIGNATURE----- |