aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2021-04-09 10:53:06 +0100
committerChristopher Baines <mail@cbaines.net>2021-04-09 10:53:06 +0100
commit6fb5eafc33efa109b220efe71594cfcdb2efe133 (patch)
treeaf6cab11bbbcb1d8a8b8fbbbda96f4d9f23f148e
parent44d00065cfbd0f24d2fac631608a5aeaace648a7 (diff)
downloadbuild-coordinator-6fb5eafc33efa109b220efe71594cfcdb2efe133.tar
build-coordinator-6fb5eafc33efa109b220efe71594cfcdb2efe133.tar.gz
Handle receiving logs as bytevectors
I think this can happen if the log doesn't arrive as a chunked HTTP request.
-rw-r--r--guix-build-coordinator/agent-messaging/http/server.scm32
1 files 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"