guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

03/07: store-copy: Display a progress bar when copying store items.


From: Ludovic Courtès
Subject: 03/07: store-copy: Display a progress bar when copying store items.
Date: Sun, 23 Sep 2018 17:34:31 -0400 (EDT)

civodul pushed a commit to branch master
in repository guix.

commit a387b0bebb151a766ca6a454a891f2370c96703c
Author: Ludovic Courtès <address@hidden>
Date:   Sun Sep 23 22:24:07 2018 +0200

    store-copy: Display a progress bar when copying store items.
    
    * guix/build/store-copy.scm (populate-store): Add #:log-port parameter.
    Use 'progress-reporter/bar' to report progress.
---
 guix/build/store-copy.scm | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/guix/build/store-copy.scm b/guix/build/store-copy.scm
index 2d9590d..64ade78 100644
--- a/guix/build/store-copy.scm
+++ b/guix/build/store-copy.scm
@@ -19,6 +19,7 @@
 (define-module (guix build store-copy)
   #:use-module (guix build utils)
   #:use-module (guix sets)
+  #:use-module (guix progress)
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-9)
   #:use-module (srfi srfi-26)
@@ -167,7 +168,8 @@ REFERENCE-GRAPHS, a list of reference-graph files."
 
   (reduce + 0 (map file-size items)))
 
-(define* (populate-store reference-graphs target)
+(define* (populate-store reference-graphs target
+                         #:key (log-port (current-error-port)))
   "Populate the store under directory TARGET with the items specified in
 REFERENCE-GRAPHS, a list of reference-graph files."
   (define store
@@ -183,9 +185,20 @@ REFERENCE-GRAPHS, a list of reference-graph files."
 
   (mkdir-p store)
   (chmod store #o1775)
-  (for-each (lambda (thing)
-              (copy-recursively thing
-                                (string-append target thing)))
-            (things-to-copy)))
+
+  (let* ((things   (things-to-copy))
+         (len      (length things))
+         (progress (progress-reporter/bar len
+                                          (format #f "copying ~a store items"
+                                                  len)
+                                          log-port)))
+    (call-with-progress-reporter progress
+      (lambda (report)
+        (for-each (lambda (thing)
+                    (copy-recursively thing
+                                      (string-append target thing)
+                                      #:log (%make-void-port "w"))
+                    (report))
+                  things)))))
 
 ;;; store-copy.scm ends here



reply via email to

[Prev in Thread] Current Thread [Next in Thread]