aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--guix-build-coordinator/agent-messaging/http/server.scm124
1 files changed, 70 insertions, 54 deletions
diff --git a/guix-build-coordinator/agent-messaging/http/server.scm b/guix-build-coordinator/agent-messaging/http/server.scm
index b8c9e2a..c001546 100644
--- a/guix-build-coordinator/agent-messaging/http/server.scm
+++ b/guix-build-coordinator/agent-messaging/http/server.scm
@@ -861,31 +861,39 @@ port. Also, the port used can be changed by passing the --port option.\n"
content-length
tmp-output-file-name))))
- (let ((channel
- (start-computing-output-hash-via-channel
- output-hash-channel
- request
- response-port
- uuid
- tmp-output-file-name
- output-file-name)))
-
- (log-msg logger
- 'DEBUG
- "PUT /build/" uuid "/output/" output-name ": "
- "finished receiving " tmp-output-file-name)
-
- (list
- (build-response
- #:code 200
- #:headers '((content-type . (text/plain))))
- (lambda (response-port)
- ;; Make sure NGinx gets the response headers
- (force-output (request-port request))
-
- (report-progress-computing-hash channel
- request
- response-port)))))
+ (if (file-exists? output-file-name)
+ (render-json
+ '(("success" . "upload already finished"))
+ #:code 200)
+ (if (file-exists? tmp-output-file-name)
+ (let ((channel
+ (start-computing-output-hash-via-channel
+ output-hash-channel
+ request
+ response-port
+ uuid
+ tmp-output-file-name
+ output-file-name)))
+
+ (log-msg logger
+ 'DEBUG
+ "PUT /build/" uuid "/output/" output-name ": "
+ "finished receiving " tmp-output-file-name)
+
+ (list
+ (build-response
+ #:code 200
+ #:headers '((content-type . (text/plain))))
+ (lambda (response-port)
+ ;; Make sure NGinx gets the response headers
+ (force-output (request-port request))
+
+ (report-progress-computing-hash channel
+ request
+ response-port))))
+ (render-json
+ '(("error" . "tmp file missing"))
+ #:code 400))))
(render-json
'(("error" . "access denied"))
#:code 403))))
@@ -945,35 +953,43 @@ port. Also, the port used can be changed by passing the --port option.\n"
tmp-output-file-name
#:append? #t)))
- (let ((channel
- (start-computing-output-hash-via-channel
- output-hash-channel
- request
- response-port
- uuid
- tmp-output-file-name
- 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
- #:code 200
- #:headers '((content-type . (text/plain))))
- (lambda (response-port)
- ;; Make sure NGinx gets the response headers
- (force-output (request-port request))
-
- (report-progress-computing-hash channel
- request
- response-port)))))
+ (if (file-exists? output-file-name)
+ (render-json
+ '(("success" . "upload already finished"))
+ #:code 200)
+ (if (file-exists? tmp-output-file-name)
+ (let ((channel
+ (start-computing-output-hash-via-channel
+ output-hash-channel
+ request
+ response-port
+ uuid
+ tmp-output-file-name
+ 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
+ #:code 200
+ #:headers '((content-type . (text/plain))))
+ (lambda (response-port)
+ ;; Make sure NGinx gets the response headers
+ (force-output (request-port request))
+
+ (report-progress-computing-hash channel
+ request
+ response-port))))
+ (render-json
+ '(("error" . "tmp file missing"))
+ #:code 400))))
(render-json
'(("error" . "access denied"))
#:code 403))))