From 6fb5eafc33efa109b220efe71594cfcdb2efe133 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Fri, 9 Apr 2021 10:53:06 +0100 Subject: Handle receiving logs as bytevectors I think this can happen if the log doesn't arrive as a chunked HTTP request. --- .../agent-messaging/http/server.scm | 32 ++++++++++++++-------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/guix-build-coordinator/agent-messaging/http/server.scm b/guix-build-coordinator/agent-messaging/http/server.scm index 552cf85..0dd453c 100644 --- a/guix-build-coordinator/agent-messaging/http/server.scm +++ b/guix-build-coordinator/agent-messaging/http/server.scm @@ -344,18 +344,26 @@ port. Also, the port used can be changed by passing the --port option.\n" (mkdir-p (dirname output-file-name)) (when (file-exists? tmp-output-file-name) (delete-file tmp-output-file-name)) - (if (call-with-worker-thread - chunked-request-channel - (lambda () - (call-with-output-file tmp-output-file-name - (lambda (output-port) - (let loop ((bv (get-bytevector-some body))) - (unless (eof-object? bv) - (put-bytevector output-port bv) - (loop (get-bytevector-some body)))))) - (rename-file tmp-output-file-name - output-file-name) - #t)) + (if (if (bytevector? body) + (begin + (call-with-output-file tmp-output-file-name + (lambda (output-port) + (put-bytevector output-port body))) + (rename-file tmp-output-file-name + output-file-name) + #t) + (call-with-worker-thread + chunked-request-channel + (lambda () + (call-with-output-file tmp-output-file-name + (lambda (output-port) + (let loop ((bv (get-bytevector-some body))) + (unless (eof-object? bv) + (put-bytevector output-port bv) + (loop (get-bytevector-some body)))))) + (rename-file tmp-output-file-name + output-file-name) + #t))) (no-content) (render-json "error" -- cgit v1.2.3