diff options
author | Marius Bakke <marius@gnu.org> | 2021-06-06 21:16:32 +0200 |
---|---|---|
committer | Marius Bakke <marius@gnu.org> | 2021-06-06 21:16:32 +0200 |
commit | 8d59c262ada2e2167196a8fb8cbebd9c329a79dd (patch) | |
tree | 85a74de8cc23a2f0179c0b9f0adfa4c274449a0c /guix/progress.scm | |
parent | e7f0835b07d868fd447aa64c873174fa385e1699 (diff) | |
parent | a068ed6a5f5b3535fce49ac4eca1fec82edd6fdc (diff) | |
download | guix-patches-8d59c262ada2e2167196a8fb8cbebd9c329a79dd.tar guix-patches-8d59c262ada2e2167196a8fb8cbebd9c329a79dd.tar.gz |
Merge branch 'master' into core-updates
Conflicts:
gnu/local.mk
gnu/packages/algebra.scm
gnu/packages/bioinformatics.scm
gnu/packages/curl.scm
gnu/packages/docbook.scm
gnu/packages/emacs-xyz.scm
gnu/packages/maths.scm
gnu/packages/plotutils.scm
gnu/packages/python-web.scm
gnu/packages/python-xyz.scm
gnu/packages/radio.scm
gnu/packages/readline.scm
gnu/packages/tls.scm
gnu/packages/xml.scm
gnu/packages/xorg.scm
Diffstat (limited to 'guix/progress.scm')
-rw-r--r-- | guix/progress.scm | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/guix/progress.scm b/guix/progress.scm index 334bd40547..0cbc804ec1 100644 --- a/guix/progress.scm +++ b/guix/progress.scm @@ -347,15 +347,25 @@ should be a <progress-reporter> object." (report total) (loop total (get-bytevector-n! in buffer 0 buffer-size)))))))) -(define* (progress-report-port reporter port #:key (close? #t)) +(define* (progress-report-port reporter port + #:key + (close? #t) + download-size) "Return a port that continuously reports the bytes read from PORT using REPORTER, which should be a <progress-reporter> object. When CLOSE? is true, -PORT is closed when the returned port is closed." +PORT is closed when the returned port is closed. + +When DOWNLOAD-SIZE is passed, do not read more than DOWNLOAD-SIZE bytes from +PORT. This is important to avoid blocking when the remote side won't close +the underlying connection." (match reporter (($ <progress-reporter> start report stop) (let* ((total 0) (read! (lambda (bv start count) - (let ((n (match (get-bytevector-n! port bv start count) + (let* ((count (if download-size + (min count (- download-size total)) + count)) + (n (match (get-bytevector-n! port bv start count) ((? eof-object?) 0) (x x)))) (set! total (+ total n)) |