diff options
Diffstat (limited to 'guix-build-coordinator/agent-messaging')
-rw-r--r-- | guix-build-coordinator/agent-messaging/http.scm | 48 |
1 files changed, 21 insertions, 27 deletions
diff --git a/guix-build-coordinator/agent-messaging/http.scm b/guix-build-coordinator/agent-messaging/http.scm index 9e60b4a..40d6653 100644 --- a/guix-build-coordinator/agent-messaging/http.scm +++ b/guix-build-coordinator/agent-messaging/http.scm @@ -321,12 +321,10 @@ port. Also, the port used can be changed by passing the --port option.\n" (lambda () (call-with-output-file output-file-name (lambda (output-port) - (let loop ((line (get-line body))) - (unless (eof-object? line) - (base64-decode line - base64-alphabet - output-port) - (loop (get-line body)))))) + (let loop ((bv (get-bytevector-some body))) + (unless (eof-object? bv) + (put-bytevector output-port bv) + (loop (get-bytevector-some body)))))) #t)) (no-content) (render-json @@ -348,48 +346,44 @@ port. Also, the port used can be changed by passing the --port option.\n" (call-with-output-file output-file-name (lambda (output-port) (let ((start-time (current-time time-utc))) - (let loop ((line (get-line body)) - (base64-characters-read 0) - (last-progress-update-characters-read 0)) - (if (eof-object? line) + (let loop ((bv (get-bytevector-some body)) + (bytes-read 0) + (last-progress-update-bytes-read 0)) + (if (eof-object? bv) (let* ((end-time (current-time time-utc)) (elapsed (time-difference end-time start-time)) (seconds-elapsed (+ (time-second elapsed) - (/ (time-nanosecond elapsed) 1e9))) - (bytes-transfered - (* 3 (/ base64-characters-read 4)))) + (/ (time-nanosecond elapsed) 1e9)))) (display (simple-format #f "receiving ~A\n took ~A seconds\n data transfered: ~AMB\n speed (MB/s): ~A\n" (basename output-file-name) seconds-elapsed - (rationalize (exact->inexact (/ bytes-transfered 1000000)) + (rationalize (exact->inexact (/ bytes-read 1000000)) 0.1) - (rationalize (/ (/ bytes-transfered 1000000) seconds-elapsed) + (rationalize (/ (/ bytes-read 1000000) seconds-elapsed) 0.1)))) (begin - (base64-decode line - base64-alphabet - output-port) - (loop (get-line body) - (+ base64-characters-read - (string-length line)) - (if (> (- base64-characters-read - last-progress-update-characters-read) - 66666666) ; ~50MB in base64 characters + (put-bytevector output-port bv) + (loop (get-bytevector-some body) + (+ bytes-read + (bytevector-length bv)) + (if (> (- bytes-read + last-progress-update-bytes-read) + 50000000) ; ~50MB (begin (display (simple-format #f "receiving ~A\n ~AMB read so far...\n" (basename output-file-name) - (rationalize (exact->inexact (/ (* 3 (/ base64-characters-read 4)) + (rationalize (exact->inexact (/ bytes-read 1000000)) 0.1))) - base64-characters-read) - last-progress-update-characters-read)))))))) + bytes-read) + last-progress-update-bytes-read)))))))) #t)) (no-content) (render-json |