aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--guix-build-coordinator/agent-messaging/http.scm12
1 files changed, 9 insertions, 3 deletions
diff --git a/guix-build-coordinator/agent-messaging/http.scm b/guix-build-coordinator/agent-messaging/http.scm
index 40d6653..61405b6 100644
--- a/guix-build-coordinator/agent-messaging/http.scm
+++ b/guix-build-coordinator/agent-messaging/http.scm
@@ -337,13 +337,17 @@ port. Also, the port used can be changed by passing the --port option.\n"
(let ((agent-id-for-build
(datastore-agent-for-build datastore uuid)))
(if (authenticated? agent-id-for-build request)
- (let ((output-file-name
- (build-output-file-location datastore uuid output-name)))
+ (let* ((output-file-name
+ (build-output-file-location datastore uuid output-name))
+ (tmp-output-file-name
+ (string-append output-file-name ".tmp")))
(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 output-file-name
+ (call-with-output-file tmp-output-file-name
(lambda (output-port)
(let ((start-time (current-time time-utc)))
(let loop ((bv (get-bytevector-some body))
@@ -384,6 +388,8 @@ port. Also, the port used can be changed by passing the --port option.\n"
0.1)))
bytes-read)
last-progress-update-bytes-read))))))))
+ (rename-file tmp-output-file-name
+ output-file-name)
#t))
(no-content)
(render-json