From 5412d515e3b0b4585ae1faf5cf3eb0a5e63a7b22 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Fri, 21 Oct 2022 12:16:56 +0100 Subject: Copy upload error handling to the partial route --- .../agent-messaging/http/server.scm | 24 ++++++++++++++++------ 1 file 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 () -- cgit v1.2.3