1 |
On 1/10/19 7:30 AM, Fabian Groffen wrote: |
2 |
> The reporting of files remaining can look somewhat odd since the report |
3 |
> interval is hardcoded to be per 1000 objects. Adjust this interval to |
4 |
> be time based. This means that modern (fast) machines likely will never |
5 |
> see the countdown messages at all. On slow setups the message will be |
6 |
> informative that there is progress, albeit rather slowly. While at it, |
7 |
> report percentage done. |
8 |
> |
9 |
> Output before this patch: |
10 |
> |
11 |
> * checking 6158 files for package collisions |
12 |
> 5158 files remaining ... |
13 |
> 4158 files remaining ... |
14 |
> 3158 files remaining ... |
15 |
> 2158 files remaining ... |
16 |
> 1158 files remaining ... |
17 |
> 158 files remaining ... |
18 |
> |
19 |
> Possible output after this patch on a slower machine: |
20 |
> |
21 |
> * checking 6158 files for package collisions |
22 |
> 48% done, 3145 files remaining ... |
23 |
> 96% done, 192 files remaining ... |
24 |
> 100% done |
25 |
> |
26 |
> Signed-off-by: Fabian Groffen <grobian@g.o> |
27 |
> --- |
28 |
> lib/portage/dbapi/vartree.py | 15 +++++++++++++-- |
29 |
> 1 file changed, 13 insertions(+), 2 deletions(-) |
30 |
> |
31 |
> diff --git a/lib/portage/dbapi/vartree.py b/lib/portage/dbapi/vartree.py |
32 |
> index 4b91caea8..909c0e473 100644 |
33 |
> --- a/lib/portage/dbapi/vartree.py |
34 |
> +++ b/lib/portage/dbapi/vartree.py |
35 |
> @@ -35,6 +35,7 @@ portage.proxy.lazyimport.lazyimport(globals(), |
36 |
> 'portage.util.install_mask:install_mask_dir,InstallMask', |
37 |
> 'portage.util.listdir:dircache,listdir', |
38 |
> 'portage.util.movefile:movefile', |
39 |
> + 'portage.util.monotonic:monotonic', |
40 |
> 'portage.util.path:first_existing,iter_parents', |
41 |
> 'portage.util.writeable_check:get_ro_checker', |
42 |
> 'portage.util._xattr:xattr', |
43 |
> @@ -3475,13 +3476,21 @@ class dblink(object): |
44 |
> symlink_collisions = [] |
45 |
> destroot = self.settings['ROOT'] |
46 |
> totfiles = len(file_list) + len(symlink_list) |
47 |
> + previous = monotonic() |
48 |
> + progress_shown = False |
49 |
> + report_interval = 1.7 # seconds |
50 |
> + falign = len("%d" % totfiles) |
51 |
> showMessage(_(" %s checking %d files for package collisions\n") % \ |
52 |
> (colorize("GOOD", "*"), totfiles)) |
53 |
> for i, (f, f_type) in enumerate(chain( |
54 |
> ((f, "reg") for f in file_list), |
55 |
> ((f, "sym") for f in symlink_list))): |
56 |
> - if i % 1000 == 0 and i != 0: |
57 |
> - showMessage(_("%d files remaining ...\n") % (totfiles - i)) |
58 |
> + current = monotonic() |
59 |
> + if current - previous > report_interval: |
60 |
> + showMessage(_("%3d%% done, %*d files remaining ...\n") % |
61 |
> + (i * 100 / totfiles, falign, totfiles - i)) |
62 |
> + previous = current |
63 |
> + progress_shown = True |
64 |
> |
65 |
> dest_path = normalize_path( |
66 |
> os.path.join(destroot, f.lstrip(os.path.sep))) |
67 |
> @@ -3570,6 +3579,8 @@ class dblink(object): |
68 |
> break |
69 |
> if stopmerge: |
70 |
> collisions.append(f) |
71 |
> + if progress_shown: |
72 |
> + showMessage(_("100% done\n")) |
73 |
> return collisions, dirs_ro, symlink_collisions, plib_collisions |
74 |
> |
75 |
> def _lstat_inode_map(self, path_iter): |
76 |
> |
77 |
|
78 |
Looks good! |
79 |
-- |
80 |
Thanks, |
81 |
Zac |