aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2022-10-21 12:16:56 +0100
committerChristopher Baines <mail@cbaines.net>2022-10-21 12:16:56 +0100
commit5412d515e3b0b4585ae1faf5cf3eb0a5e63a7b22 (patch)
tree01d9c11a95c063e70e9517ba11d666cafe6e9043
parentb782e752205422054c932bd3a8196dcfdc33b346 (diff)
downloadbuild-coordinator-5412d515e3b0b4585ae1faf5cf3eb0a5e63a7b22.tar
build-coordinator-5412d515e3b0b4585ae1faf5cf3eb0a5e63a7b22.tar.gz
Copy upload error handling to the partial route
-rw-r--r--guix-build-coordinator/agent-messaging/http/server.scm24
1 files changed, 18 insertions, 6 deletions
diff --git a/guix-build-coordinator/agent-messaging/http/server.scm b/guix-build-coordinator/agent-messaging/http/server.scm
index 7facaa3..e4f7041 100644
--- a/guix-build-coordinator/agent-messaging/http/server.scm
+++ b/guix-build-coordinator/agent-messaging/http/server.scm
@@ -564,12 +564,24 @@ port. Also, the port used can be changed by passing the --port option.\n"
(simple-format #f "error computing hash: ~A" exn))
(when (file-exists? file-name)
- ;; I've seen exceptions happen here from lzip, so try
- ;; deleting the tmp file so that it's re-uploaded.
- (log-msg logger
- 'WARN
- (simple-format #f "deleting ~A" file-name))
- (delete-file file-name))
+ (let ((md5-hash
+ (bytevector->base16-string
+ (file-hash (hash-algorithm md5) file-name)))
+ (file-bytes
+ (stat:size (stat file-name))))
+ ;; I've seen exceptions happen here from lzip, so try
+ ;; deleting the tmp file so that it's re-uploaded.
+ (log-msg logger
+ 'WARN
+ (simple-format #f "deleting ~A" file-name))
+ (delete-file file-name)
+
+ (raise-exception
+ (make-exception
+ exn
+ (make-exception-with-irritants
+ `((file-bytes . ,file-bytes)
+ (md5-hash . ,md5-hash)))))))
(raise-exception exn))
(lambda ()