aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2015-02-27 14:56:01 +0100
committerLudovic Courtès <ludo@gnu.org>2015-02-27 15:08:37 +0100
commit2c1fb35377182d3301a265945c88deb12f0b88d4 (patch)
tree29ad6beab05c7a636e2d9c0a362e41e81c08c2e8
parent251e8b2ee8a9cb89ce662b9c47d9dcd76dec618b (diff)
downloadgnu-guix-2c1fb35377182d3301a265945c88deb12f0b88d4.tar
gnu-guix-2c1fb35377182d3301a265945c88deb12f0b88d4.tar.gz
utils: Call the progress-report proc when 'dump-port' starts.
* guix/build/utils.scm (dump-port): Add call to PROGRESS at the beginning.
-rw-r--r--guix/build/utils.scm19
1 files changed, 12 insertions, 7 deletions
diff --git a/guix/build/utils.scm b/guix/build/utils.scm
index f43451bd35..a3f8911491 100644
--- a/guix/build/utils.scm
+++ b/guix/build/utils.scm
@@ -588,22 +588,27 @@ match the terminating newline of a line."
(define* (dump-port in out
#:key (buffer-size 16384)
(progress (lambda (t k) (k))))
- "Read as much data as possible from IN and write it to OUT, using
-chunks of BUFFER-SIZE bytes. Call PROGRESS after each successful
-transfer of BUFFER-SIZE bytes or less, passing it the total number of
-bytes transferred and the continuation of the transfer as a thunk."
+ "Read as much data as possible from IN and write it to OUT, using chunks of
+BUFFER-SIZE bytes. Call PROGRESS at the beginning and after each successful
+transfer of BUFFER-SIZE bytes or less, passing it the total number of bytes
+transferred and the continuation of the transfer as a thunk."
(define buffer
(make-bytevector buffer-size))
- (let loop ((total 0)
- (bytes (get-bytevector-n! in buffer 0 buffer-size)))
+ (define (loop total bytes)
(or (eof-object? bytes)
(let ((total (+ total bytes)))
(put-bytevector out buffer 0 bytes)
(progress total
(lambda ()
(loop total
- (get-bytevector-n! in buffer 0 buffer-size))))))))
+ (get-bytevector-n! in buffer 0 buffer-size)))))))
+
+ ;; Make sure PROGRESS is called when we start so that it can measure
+ ;; throughput.
+ (progress 0
+ (lambda ()
+ (loop 0 (get-bytevector-n! in buffer 0 buffer-size)))))
(define (set-file-time file stat)
"Set the atime/mtime of FILE to that specified by STAT."