all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [bug#45146] [PATCH] scripts: substitute: Improve fetch-narinfos progress reporting.
@ 2020-12-09 18:57 Christopher Baines
  2020-12-11 18:01 ` Ludovic Courtès
  2021-02-24 20:34 ` [bug#45146] [PATCH 1/2] guix: substitutes: Make progress reporting configurable Christopher Baines
  0 siblings, 2 replies; 7+ messages in thread
From: Christopher Baines @ 2020-12-09 18:57 UTC (permalink / raw)
  To: 45146

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





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

end of thread, other threads:[~2021-03-09 20:57 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-09 18:57 [bug#45146] [PATCH] scripts: substitute: Improve fetch-narinfos progress reporting Christopher Baines
2020-12-11 18:01 ` 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

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.