1 |
On Fri, 6 Nov 2015 20:59:06 -0800 |
2 |
Zac Medico <zmedico@g.o> wrote: |
3 |
|
4 |
> Fix flaws in logic involving the updatecache_flg variable, in order |
5 |
> to skip metadata-transfer when sync fails (or the server timestamp |
6 |
> has not changed). |
7 |
> |
8 |
> X-Gentoo-Bug: 564988 |
9 |
> X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=564988 |
10 |
> --- |
11 |
> pym/portage/sync/modules/rsync/rsync.py | 17 ++++++++++------- |
12 |
> 1 file changed, 10 insertions(+), 7 deletions(-) |
13 |
> |
14 |
> diff --git a/pym/portage/sync/modules/rsync/rsync.py |
15 |
> b/pym/portage/sync/modules/rsync/rsync.py index 8ae8a5c..e0f76b3 |
16 |
> 100644 --- a/pym/portage/sync/modules/rsync/rsync.py |
17 |
> +++ b/pym/portage/sync/modules/rsync/rsync.py |
18 |
> @@ -112,10 +112,10 @@ class RsyncSync(NewBase): |
19 |
> if syncuri.startswith("file://"): |
20 |
> self.proto = "file" |
21 |
> dosyncuri = syncuri[6:] |
22 |
> - is_synced, exitcode = self._do_rsync( |
23 |
> + is_synced, exitcode, updatecache_flg = |
24 |
> self._do_rsync( dosyncuri, timestamp, opts) |
25 |
> self._process_exitcode(exitcode, dosyncuri, |
26 |
> out, 1) |
27 |
> - return (exitcode, exitcode == os.EX_OK) |
28 |
> + return (exitcode, updatecache_flg) |
29 |
> |
30 |
> retries=0 |
31 |
> try: |
32 |
> @@ -138,7 +138,7 @@ class RsyncSync(NewBase): |
33 |
> else: |
34 |
> # getaddrinfo needs the brackets stripped |
35 |
> getaddrinfo_host = hostname[1:-1] |
36 |
> - updatecache_flg=True |
37 |
> + updatecache_flg = False |
38 |
> all_rsync_opts = set(self.rsync_opts) |
39 |
> all_rsync_opts.update(self.extra_rsync_opts) |
40 |
> |
41 |
> @@ -240,7 +240,8 @@ class RsyncSync(NewBase): |
42 |
> if dosyncuri.startswith('ssh://'): |
43 |
> dosyncuri = |
44 |
> dosyncuri[6:].replace('/', ':/', 1) |
45 |
> - is_synced, exitcode = |
46 |
> self._do_rsync(dosyncuri, timestamp, opts) |
47 |
> + is_synced, exitcode, updatecache_flg = |
48 |
> self._do_rsync( |
49 |
> + dosyncuri, timestamp, opts) |
50 |
> if is_synced: |
51 |
> break |
52 |
> |
53 |
> @@ -251,7 +252,6 @@ class RsyncSync(NewBase): |
54 |
> else: |
55 |
> # over retries |
56 |
> # exit loop |
57 |
> - updatecache_flg=False |
58 |
> exitcode = EXCEEDED_MAX_RETRIES |
59 |
> break |
60 |
> self._process_exitcode(exitcode, dosyncuri, out, |
61 |
> maxretries) @@ -382,6 +382,7 @@ class RsyncSync(NewBase): |
62 |
> |
63 |
> |
64 |
> def _do_rsync(self, syncuri, timestamp, opts): |
65 |
> + updatecache_flg = False |
66 |
> is_synced = False |
67 |
> if timestamp != 0 and "--quiet" not in opts: |
68 |
> print(">>> Checking server timestamp ...") |
69 |
> @@ -489,7 +490,7 @@ class RsyncSync(NewBase): |
70 |
> print(">>> In order to force sync, |
71 |
> remove '%s'." % self.servertimestampfile) print(">>>") |
72 |
> print() |
73 |
> - return is_synced, exitcode |
74 |
> + return is_synced, exitcode, |
75 |
> updatecache_flg elif (servertimestamp != 0) and (servertimestamp < |
76 |
> timestamp): self.logger(self.xterm_titles, |
77 |
> ">>> Server out of date: %s" |
78 |
> % syncuri) @@ -543,6 +544,8 @@ class RsyncSync(NewBase): |
79 |
> os.unlink(self.servertimestampfile) |
80 |
> except OSError: |
81 |
> pass |
82 |
> + else: |
83 |
> + updatecache_flg = |
84 |
> True |
85 |
> if exitcode in [0,1,3,4,11,14,20,21]: |
86 |
> is_synced = True |
87 |
> @@ -554,4 +557,4 @@ class RsyncSync(NewBase): |
88 |
> # --prune-empty-directories. Retry for a |
89 |
> server that supports # at least rsync protocol version 29 |
90 |
> (>=rsync-2.6.4). pass |
91 |
> - return is_synced, exitcode |
92 |
> + return is_synced, exitcode, updatecache_flg |
93 |
|
94 |
|
95 |
it'll work for me ;) |
96 |
-- |
97 |
Brian Dolbec <dolsen> |