ssh: Fix progress bar crash when there are zero items to send.

* guix/ssh.scm (notify-transfer-progress): Do nothing when TOTAL is
zero.
This commit is contained in:
Ludovic Courtès 2020-09-02 23:58:34 +02:00
parent de83660dd3
commit 44c6e6f590
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5

View file

@ -441,6 +441,7 @@ (define (display-bar %)
(progress-bar % (- (max (current-terminal-columns) 5) 5))) (progress-bar % (- (max (current-terminal-columns) 5) 5)))
(force-output port)) (force-output port))
(unless (zero? total)
(let ((% (* 100. (/ sent total)))) (let ((% (* 100. (/ sent total))))
(match (vhash-assoc item sizes) (match (vhash-assoc item sizes)
(#f (#f
@ -448,7 +449,7 @@ (define (display-bar %)
(values port sizes total sent)) (values port sizes total sent))
((_ . size) ((_ . size)
(display-bar %) (display-bar %)
(values port sizes total (+ sent size)))))) (values port sizes total (+ sent size)))))))
(define (notify-transfer-completion port . args) (define (notify-transfer-completion port . args)
"Notify the user that the transfer has completed." "Notify the user that the transfer has completed."