diff options
-rw-r--r-- | guix-build-coordinator/agent-messaging/http/server.scm | 65 |
1 files changed, 37 insertions, 28 deletions
diff --git a/guix-build-coordinator/agent-messaging/http/server.scm b/guix-build-coordinator/agent-messaging/http/server.scm index 806c201..b8c9e2a 100644 --- a/guix-build-coordinator/agent-messaging/http/server.scm +++ b/guix-build-coordinator/agent-messaging/http/server.scm @@ -915,30 +915,35 @@ port. Also, the port used can be changed by passing the --port option.\n" (let* ((output-file-name (build-output-file-location datastore uuid output-name)) (tmp-output-file-name - (string-append output-file-name ".tmp"))) - - ;; If the output file exists, delete it, as it's being uploaded - ;; again - (when (file-exists? output-file-name) - (log-msg logger - 'WARN - "POST /build/" uuid "/output/" output-name "/partial: " - "deleting " output-file-name) - (delete-file output-file-name)) - - (if (member '(chunked) (request-transfer-encoding request)) - ;; Older agents may use chunked encoding for this request - (call-with-worker-thread - chunked-request-channel - (lambda () - (receive-file body - #f - tmp-output-file-name - #:append? #t))) - (receive-file body - (request-content-length request) - tmp-output-file-name - #:append? #t)) + (string-append output-file-name ".tmp")) + (content-length + (request-content-length request))) + + ;; An agent may make this request with a content length of 0 to + ;; resume waiting for the hash to be computed + (unless (= content-length 0) + ;; If the output file exists, delete it, as it's being uploaded + ;; again + (when (file-exists? output-file-name) + (log-msg logger + 'WARN + "POST /build/" uuid "/output/" output-name "/partial: " + "deleting " output-file-name) + (delete-file output-file-name)) + + (if (member '(chunked) (request-transfer-encoding request)) + ;; Older agents may use chunked encoding for this request + (call-with-worker-thread + chunked-request-channel + (lambda () + (receive-file body + #f + tmp-output-file-name + #:append? #t))) + (receive-file body + (request-content-length request) + tmp-output-file-name + #:append? #t))) (let ((channel (start-computing-output-hash-via-channel @@ -949,10 +954,14 @@ port. Also, the port used can be changed by passing the --port option.\n" tmp-output-file-name output-file-name))) - (log-msg logger - 'DEBUG - "POST /build/" uuid "/output/" output-name "/partial: " - "finished receiving " tmp-output-file-name) + (apply log-msg + logger + 'DEBUG + "POST /build/" uuid "/output/" output-name "/partial: " + (if (= content-length 0) + `("sending response for " ,tmp-output-file-name + " upload") + `("finished receiving " ,tmp-output-file-name))) (list (build-response |