[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
05/08: utils: Call the progress-report proc when 'dump-port' starts.
From: |
Ludovic Courtès |
Subject: |
05/08: utils: Call the progress-report proc when 'dump-port' starts. |
Date: |
Fri, 27 Feb 2015 14:09:07 +0000 |
civodul pushed a commit to branch core-updates
in repository guix.
commit 2c1fb35377182d3301a265945c88deb12f0b88d4
Author: Ludovic Courtès <address@hidden>
Date: Fri Feb 27 14:56:01 2015 +0100
utils: Call the progress-report proc when 'dump-port' starts.
* guix/build/utils.scm (dump-port): Add call to PROGRESS at the
beginning.
---
guix/build/utils.scm | 19 ++++++++++++-------
1 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/guix/build/utils.scm b/guix/build/utils.scm
index f43451b..a3f8911 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."
- branch core-updates updated (50915d2 -> c9727aa), Ludovic Courtès, 2015/02/27
- 01/08: gnu: gettext: Set encoding to ISO-8859-1 when modifying files., Ludovic Courtès, 2015/02/27
- 04/08: build-system/gnu: Set $LC_ALL (or similar) to the chosen locale., Ludovic Courtès, 2015/02/27
- 05/08: utils: Call the progress-report proc when 'dump-port' starts.,
Ludovic Courtès <=
- 02/08: gnu: Remove now unneeded 'unpack' phases for unzip., Ludovic Courtès, 2015/02/27
- 06/08: download: Abstract the receive buffer size., Ludovic Courtès, 2015/02/27
- 08/08: download: Comment on lack of progress report with chunked encoding., Ludovic Courtès, 2015/02/27
- 03/08: gnu: Remove now unneeded 'localedef' invocations., Ludovic Courtès, 2015/02/27
- 07/08: download: Measure and display the throughput., Ludovic Courtès, 2015/02/27