diff options
author | Marius Bakke <mbakke@fastmail.com> | 2018-11-20 01:14:12 +0100 |
---|---|---|
committer | Marius Bakke <mbakke@fastmail.com> | 2018-11-20 01:14:12 +0100 |
commit | 4f70db97a040b35f125484ce8885766ca5807dd4 (patch) | |
tree | 30274f4a57e4a149127125fb6df626dd1d9f9cf0 /guix/progress.scm | |
parent | 2d546858b139e5fcf2cbdf9958a17fd98803ac4c (diff) | |
parent | 9acfe275adf1bc27483ba58c6d86a84ba20aa08f (diff) |
Merge branch 'master' into core-updates
Diffstat (limited to 'guix/progress.scm')
-rw-r--r-- | guix/progress.scm | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/guix/progress.scm b/guix/progress.scm index 9da667a027..65080bcf24 100644 --- a/guix/progress.scm +++ b/guix/progress.scm @@ -2,6 +2,7 @@ ;;; Copyright © 2017 Sou Bunnbu <iyzsong@gmail.com> ;;; Copyright © 2015 Steve Sprang <scs@stevesprang.com> ;;; Copyright © 2017, 2018 Ludovic Courtès <ludo@gnu.org> +;;; Copyright © 2018 Clément Lassieur <clement@lassieur.org> ;;; ;;; This file is part of GNU Guix. ;;; @@ -197,7 +198,7 @@ throughput." (define elapsed (duration->seconds (time-difference (current-time time-monotonic) start-time))) - (if (number? size) + (if (and (number? size) (not (zero? size))) (let* ((% (* 100.0 (/ transferred size))) (throughput (/ transferred elapsed)) (left (format #f " ~a ~a" file @@ -211,17 +212,20 @@ throughput." (current-terminal-columns)) log-port) (force-output log-port)) - (let* ((throughput (/ transferred elapsed)) - (left (format #f " ~a" file)) - (right (format #f "~a/s ~a | ~a transferred" - (byte-count->string throughput) - (seconds->string elapsed) - (byte-count->string transferred)))) - (erase-current-line log-port) - (display (string-pad-middle left right - (current-terminal-columns)) - 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)) + (left (format #f " ~a" file)) + (right (format #f "~a/s ~a | ~a transferred" + (byte-count->string throughput) + (seconds->string elapsed) + (byte-count->string transferred)))) + (erase-current-line log-port) + (display (string-pad-middle left right + (current-terminal-columns)) + log-port) + (force-output log-port))))) (define %progress-interval ;; Default interval between subsequent outputs for rate-limited displays. |