public inbox for gentoo-portage-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-portage-dev] [PATCH] lib/portage/dbapi/vartree: use dynamic report interval in _collision_protect
@ 2019-01-07 14:31 Fabian Groffen
  2019-01-07 18:54 ` Zac Medico
                   ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: Fabian Groffen @ 2019-01-07 14:31 UTC (permalink / raw
  To: gentoo-portage-dev; +Cc: Fabian Groffen

The reporting of files remaining can look somewhat odd since the report
interval is hardcoded to be per 1000 objects.  Adjust this interval to
be regular towards the end.  While at it, report percentage done.

Output before this patch:

 * checking 6111 files for package collisions
5111 files remaining ...
4111 files remaining ...
3111 files remaining ...
2111 files remaining ...
1111 files remaining ...
111 files remaining ...

After:

 * checking 6158 files for package collisions
16% done, 5131 files remaining ...
33% done, 4104 files remaining ...
50% done, 3077 files remaining ...
66% done, 2050 files remaining ...
83% done, 1023 files remaining ...

Signed-off-by: Fabian Groffen <grobian@gentoo.org>
---
 lib/portage/dbapi/vartree.py | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/lib/portage/dbapi/vartree.py b/lib/portage/dbapi/vartree.py
index 4b91caea8..4d0bf2789 100644
--- a/lib/portage/dbapi/vartree.py
+++ b/lib/portage/dbapi/vartree.py
@@ -3475,13 +3475,19 @@ class dblink(object):
 			symlink_collisions = []
 			destroot = self.settings['ROOT']
 			totfiles = len(file_list) + len(symlink_list)
+			bucksize = 1000
+			buckcnt = int(totfiles / bucksize)
+			if buckcnt == 0 or totfiles % bucksize > int(bucksize / 2):
+				buckcnt = buckcnt + 1
+			bucksize = int(totfiles / buckcnt) + 1
 			showMessage(_(" %s checking %d files for package collisions\n") % \
 				(colorize("GOOD", "*"), totfiles))
 			for i, (f, f_type) in enumerate(chain(
 				((f, "reg") for f in file_list),
 				((f, "sym") for f in symlink_list))):
-				if i % 1000 == 0 and i != 0:
-					showMessage(_("%d files remaining ...\n") % (totfiles - i))
+				if i % bucksize == 0 and i != 0:
+					showMessage(_("%2d%% done, %d files remaining ...\n") %
+							(i * 100 / totfiles, totfiles - i))
 
 				dest_path = normalize_path(
 					os.path.join(destroot, f.lstrip(os.path.sep)))
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2019-01-11 10:17 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-01-07 14:31 [gentoo-portage-dev] [PATCH] lib/portage/dbapi/vartree: use dynamic report interval in _collision_protect Fabian Groffen
2019-01-07 18:54 ` Zac Medico
2019-01-07 19:05 ` Michał Górny
2019-01-08  8:09   ` [gentoo-portage-dev] [PATCH] collision_protect: use dynamic report interval Fabian Groffen
2019-01-08  8:17     ` Ulrich Mueller
2019-01-08  8:18       ` Fabian Groffen
2019-01-08 13:42 ` [gentoo-portage-dev] [PATCH v3] " Fabian Groffen
2019-01-08 19:15   ` Zac Medico
2019-01-08 20:59     ` M. J. Everitt
2019-01-09  8:09       ` Fabian Groffen
2019-01-09  8:33   ` [gentoo-portage-dev] [PATCH v4] " Fabian Groffen
2019-01-10  5:22     ` Zac Medico
2019-01-10  8:22       ` Fabian Groffen
2019-01-10 15:30     ` [gentoo-portage-dev] [PATCH v5] " Fabian Groffen
2019-01-11  4:37       ` Zac Medico
2019-01-11 10:16         ` Fabian Groffen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox