progress: Generate valid 'download-progress' traces when the size is unknown.

Fixes <https://bugs.gnu.org/32895>.
Reported by Ricardo Wurmus <ricardo.wurmus@mdc-berlin.de>.

* guix/progress.scm (progress-reporter/trace): In 'stop', make sure SIZE
is an integer.  Previously we'd generate a "@ download-progress" trace
with #f for the 'transferred' number when downloading files whose size
is not known in advance.
This commit is contained in:
Ludovic Courtès 2018-10-04 10:24:34 +02:00
parent ff30bb010b
commit 1d0be47ab6
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
1 changed files with 6 additions and 6 deletions

View File

@ -304,12 +304,12 @@ progress reports, write \"build trace\" lines to be processed elsewhere."
log-port))) log-port)))
(report (rate-limited report-progress %progress-interval)) (report (rate-limited report-progress %progress-interval))
(stop (lambda () (stop (lambda ()
(report-progress size) (let ((size (or (and=> (stat file #f) stat:size)
(display (format #f "@ download-succeeded ~a ~a ~a~%" size)))
file url (report-progress size)
(or (and=> (stat file #f) stat:size) (display (format #f "@ download-succeeded ~a ~a ~a~%"
size)) file url size)
log-port))))) log-port))))))
;; TODO: replace '(@ (guix build utils) dump-port))'. ;; TODO: replace '(@ (guix build utils) dump-port))'.
(define* (dump-port* in out (define* (dump-port* in out