From: Christopher Baines <mail@cbaines.net>
To: 45146@debbugs.gnu.org
Subject: [bug#45146] [PATCH] scripts: substitute: Improve fetch-narinfos progress reporting.
Date: Wed, 9 Dec 2020 18:57:59 +0000 [thread overview]
Message-ID: <20201209185759.30937-1-mail@cbaines.net> (raw)
At least in guix weather, these changes make the progress bar actually appear.
* guix/scripts/substitute.scm (fetch-narinfos): Use (guix progress) for
progress reporting.
---
guix/scripts/substitute.scm | 18 +++++-------------
1 file changed, 5 insertions(+), 13 deletions(-)
diff --git a/guix/scripts/substitute.scm b/guix/scripts/substitute.scm
index 25075eedff..5128310439 100755
--- a/guix/scripts/substitute.scm
+++ b/guix/scripts/substitute.scm
@@ -614,16 +614,8 @@ print a warning and return #f."
(define (fetch-narinfos url paths)
"Retrieve all the narinfos for PATHS from the cache at URL and return them."
- (define update-progress!
- (let ((done 0)
- (total (length paths)))
- (lambda ()
- (display "\r\x1b[K" (current-error-port)) ;erase current line
- (force-output (current-error-port))
- (format (current-error-port)
- (G_ "updating substitutes from '~a'... ~5,1f%")
- url (* 100. (/ done total)))
- (set! done (+ 1 done)))))
+ (define fetch-narinfos-progress-reporter
+ (progress-reporter/bar (length paths)))
(define hash-part->path
(let ((mapping (fold (lambda (path result)
@@ -641,7 +633,7 @@ print a warning and return #f."
(len (response-content-length response))
(cache (response-cache-control response))
(ttl (and cache (assoc-ref cache 'max-age))))
- (update-progress!)
+ (progress-reporter-report! fetch-narinfos-progress-reporter)
;; Make sure to read no more than LEN bytes since subsequent bytes may
;; belong to the next response.
@@ -673,7 +665,7 @@ print a warning and return #f."
(#f
'())
(port
- (update-progress!)
+ (start-progress-reporter! fetch-narinfos-progress-reporter)
;; Note: Do not check HTTPS server certificates to avoid depending
;; on the X.509 PKI. We can do it because we authenticate
;; narinfos, which provides a much stronger guarantee.
@@ -683,7 +675,7 @@ print a warning and return #f."
#:verify-certificate? #f
#:port port)))
(close-port port)
- (newline (current-error-port))
+ (stop-progress-reporter! fetch-narinfos-progress-reporter)
result)))))
((file #f)
(let* ((base (string-append (uri-path uri) "/"))
--
2.29.2
next reply other threads:[~2020-12-09 19:44 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-09 18:57 Christopher Baines [this message]
2020-12-11 18:01 ` [bug#45146] [PATCH] scripts: substitute: Improve fetch-narinfos progress reporting Ludovic Courtès
2020-12-24 17:26 ` Christopher Baines
2021-02-24 20:44 ` Christopher Baines
2021-03-09 20:29 ` bug#45146: " Christopher Baines
2021-02-24 20:34 ` [bug#45146] [PATCH 1/2] guix: substitutes: Make progress reporting configurable Christopher Baines
2021-02-24 20:34 ` [bug#45146] [PATCH 2/2] weather: Call lookup-narinfos with a custom progress reporter Christopher Baines
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201209185759.30937-1-mail@cbaines.net \
--to=mail@cbaines.net \
--cc=45146@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.