progress: Do not display the last 0B transfer when size is unknown.

* guix/progress.scm (display-download-progress): Don't display anything when
both SIZE and TRANSFERRED are null.
This commit is contained in:
Clément Lassieur 2018-11-14 09:16:43 +01:00
parent 0289dc1473
commit d827fd31ca
No known key found for this signature in database
GPG Key ID: 89F96D4808F359C7
1 changed files with 14 additions and 11 deletions

View File

@ -212,6 +212,9 @@ throughput."
(current-terminal-columns)) (current-terminal-columns))
log-port) log-port)
(force-output log-port)) (force-output log-port))
;; If we don't know the total size, the last transfer will have a 0B
;; size. Don't display it.
(unless (zero? transferred)
(let* ((throughput (/ transferred elapsed)) (let* ((throughput (/ transferred elapsed))
(left (format #f " ~a" file)) (left (format #f " ~a" file))
(right (format #f "~a/s ~a | ~a transferred" (right (format #f "~a/s ~a | ~a transferred"
@ -222,7 +225,7 @@ throughput."
(display (string-pad-middle left right (display (string-pad-middle left right
(current-terminal-columns)) (current-terminal-columns))
log-port) log-port)
(force-output log-port)))) (force-output log-port)))))
(define %progress-interval (define %progress-interval
;; Default interval between subsequent outputs for rate-limited displays. ;; Default interval between subsequent outputs for rate-limited displays.