From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id cNC0Cjsp0V/gDQAA0tVLHw (envelope-from ) for ; Wed, 09 Dec 2020 19:44:59 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id iEd6Bjsp0V/OawAAbx9fmQ (envelope-from ) for ; Wed, 09 Dec 2020 19:44:59 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id D3E17940149 for ; Wed, 9 Dec 2020 19:44:58 +0000 (UTC) Received: from localhost ([::1]:48986 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kn5OS-0003a9-MY for larch@yhetil.org; Wed, 09 Dec 2020 14:44:57 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35348) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kn4g3-0007pe-FF for guix-patches@gnu.org; Wed, 09 Dec 2020 13:59:04 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:52784) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kn4g2-0007Cw-Jo for guix-patches@gnu.org; Wed, 09 Dec 2020 13:59:03 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kn4g2-0003cn-JV for guix-patches@gnu.org; Wed, 09 Dec 2020 13:59:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#45146] [PATCH] scripts: substitute: Improve fetch-narinfos progress reporting. Resent-From: Christopher Baines Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 09 Dec 2020 18:59:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 45146 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 45146@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.160754029913879 (code B ref -1); Wed, 09 Dec 2020 18:59:02 +0000 Received: (at submit) by debbugs.gnu.org; 9 Dec 2020 18:58:19 +0000 Received: from localhost ([127.0.0.1]:36097 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kn4fK-0003bm-Qr for submit@debbugs.gnu.org; Wed, 09 Dec 2020 13:58:19 -0500 Received: from lists.gnu.org ([209.51.188.17]:38998) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kn4fJ-0003be-HA for submit@debbugs.gnu.org; Wed, 09 Dec 2020 13:58:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35318) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kn4fJ-0006dW-4F for guix-patches@gnu.org; Wed, 09 Dec 2020 13:58:17 -0500 Received: from mira.cbaines.net ([2a01:7e00:e000:2f8:fd4d:b5c7:13fb:3d27]:42237) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kn4f5-0006v7-Bx for guix-patches@gnu.org; Wed, 09 Dec 2020 13:58:16 -0500 Received: from localhost (188.28.127.185.threembb.co.uk [188.28.127.185]) by mira.cbaines.net (Postfix) with ESMTPSA id 5CC6B27BC02 for ; Wed, 9 Dec 2020 18:58:01 +0000 (GMT) Received: from localhost (localhost [local]) by localhost (OpenSMTPD) with ESMTPA id dd0d6867 for ; Wed, 9 Dec 2020 18:57:59 +0000 (UTC) From: Christopher Baines Date: Wed, 9 Dec 2020 18:57:59 +0000 Message-Id: <20201209185759.30937-1-mail@cbaines.net> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2a01:7e00:e000:2f8:fd4d:b5c7:13fb:3d27; envelope-from=mail@cbaines.net; helo=mira.cbaines.net X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: 4.20 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Queue-Id: D3E17940149 X-Spam-Score: 4.20 X-Migadu-Scanner: scn1.migadu.com X-TUID: ECXljyn+xP7B 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