mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2025-01-24 11:39:46 -05:00
progress: Fix total size in "@ download-succeeded" traces.
Fixes a regression introduced in
1d0be47ab6
whereby the total size for
directories (coming from substitutes) would be 4KiB. This led the
progress bar to go back to the start, typically.
* guix/progress.scm (progress-reporter/trace): Add 'total'. In 'start',
initialize it. Adjust 'report' to update it. Adjust 'stop' to prefer
SIZE as the actual size and then TOTAL. Do not use the size of FILE as
the total since that could be 4KiB when FILE is a directory.
This commit is contained in:
parent
11ff2adc74
commit
42384b517e
1 changed files with 8 additions and 3 deletions
|
@ -289,6 +289,8 @@ (define* (progress-reporter/trace file url size
|
|||
#:optional (log-port (current-output-port)))
|
||||
"Like 'progress-reporter/file', but instead of returning human-readable
|
||||
progress reports, write \"build trace\" lines to be processed elsewhere."
|
||||
(define total 0) ;bytes transferred
|
||||
|
||||
(define (report-progress transferred)
|
||||
(define message
|
||||
(format #f "@ download-progress ~a ~a ~a ~a~%"
|
||||
|
@ -299,13 +301,16 @@ (define message
|
|||
|
||||
(progress-reporter
|
||||
(start (lambda ()
|
||||
(set! total 0)
|
||||
(display (format #f "@ download-started ~a ~a ~a~%"
|
||||
file url (or size "-"))
|
||||
log-port)))
|
||||
(report (rate-limited report-progress %progress-interval))
|
||||
(report (let ((report (rate-limited report-progress %progress-interval)))
|
||||
(lambda (transferred)
|
||||
(set! total transferred)
|
||||
(report transferred))))
|
||||
(stop (lambda ()
|
||||
(let ((size (or (and=> (stat file #f) stat:size)
|
||||
size)))
|
||||
(let ((size (or size total)))
|
||||
(report-progress size)
|
||||
(display (format #f "@ download-succeeded ~a ~a ~a~%"
|
||||
file url size)
|
||||
|
|
Loading…
Reference in a new issue