diff options
author | Clément Lassieur <clement@lassieur.org> | 2018-11-14 09:16:43 +0100 |
---|---|---|
committer | Clément Lassieur <clement@lassieur.org> | 2018-11-16 14:53:44 +0100 |
commit | d827fd31ca19b2f81252cbe4e8bc982dd453a49a (patch) | |
tree | 06cbdeb44a48cfa600f94b14c06a4a664764e5dc | |
parent | 0289dc14732a64016f66e3a83f765e319960903b (diff) | |
download | gnu-guix-d827fd31ca19b2f81252cbe4e8bc982dd453a49a.tar gnu-guix-d827fd31ca19b2f81252cbe4e8bc982dd453a49a.tar.gz |
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.
-rw-r--r-- | guix/progress.scm | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/guix/progress.scm b/guix/progress.scm index 7a25f11bd4..65080bcf24 100644 --- a/guix/progress.scm +++ b/guix/progress.scm @@ -212,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. |