Reading the files database can take a while on machines with slow disks and an empty cache. To make the wait more tolerable and if stdout is a terminal, display a progress indicator (going to some lengths to avoid updating the display too often). --- src/filesdb.c | 14 ++++++++++++-- 1 files changed, 12 insertions(+), 2 deletions(-)
GNU ChangeLog entry, if still necessary: 2009-02-20 Romain Francoise <[email protected]> * src/filesdb.c (ensure_allinstfiles_available): If stdout is a terminal, display a progress indicator. diff --git a/src/filesdb.c b/src/filesdb.c index 97fe767..f83d2e5 100644 --- a/src/filesdb.c +++ b/src/filesdb.c @@ -208,19 +208,29 @@ void ensure_packagefiles_available(struct pkginfo *pkg) { void ensure_allinstfiles_available(void) { struct pkgiterator *it; struct pkginfo *pkg; - + int fancy = isatty(1), cur, last = 0, count = 0, max = countpackages(); + if (allpackagesdone) return; if (saidread<2) { saidread=1; printf(_("(Reading database ... ")); } it= iterpkgstart(); - while ((pkg = iterpkgnext(it)) != NULL) + while ((pkg = iterpkgnext(it)) != NULL) { ensure_packagefiles_available(pkg); + if (saidread == 1 && fancy) { + cur = (++count * 100) / max; + if (!(cur % 5) && cur > last) + printf("\r%s%d%%", _("(Reading database ... "), cur); + last = cur; + } + } iterpkgend(it); allpackagesdone= 1; if (saidread==1) { + if (fancy) + printf("\r%s", _("(Reading database ... ")); printf(_("%d files and directories currently installed.)\n"),nfiles); saidread=2; } -- 1.6.2.rc1.20.g8c5b -- To UNSUBSCRIBE, email to [email protected] with a subject of "unsubscribe". Trouble? Contact [email protected]

