aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2022-10-21 11:32:51 +0100
committerChristopher Baines <mail@cbaines.net>2022-10-21 11:32:51 +0100
commit5156d4d354fd7d7c5986d36180dd8dcfd639d90a (patch)
treef6970f1114a6cbf435f124b6750eebb1219ad660
parentdf85c9e7d3f0ef49f761f43e0edf105bf31949c7 (diff)
downloadbuild-coordinator-5156d4d354fd7d7c5986d36180dd8dcfd639d90a.tar
build-coordinator-5156d4d354fd7d7c5986d36180dd8dcfd639d90a.tar.gz
Include the file size and md5 hash in error messages
When an error occurs while trying to compute the hash, as I hope this information will help to identify where things have gone wrong.
-rw-r--r--guix-build-coordinator/agent-messaging/http/server.scm25
1 files changed, 19 insertions, 6 deletions
diff --git a/guix-build-coordinator/agent-messaging/http/server.scm b/guix-build-coordinator/agent-messaging/http/server.scm
index 16d42ea..7facaa3 100644
--- a/guix-build-coordinator/agent-messaging/http/server.scm
+++ b/guix-build-coordinator/agent-messaging/http/server.scm
@@ -37,6 +37,7 @@
#:use-module (web response)
#:use-module (web uri)
#:use-module (lzlib)
+ #:use-module (gcrypt base16)
#:use-module (gcrypt hash)
#:use-module (prometheus)
#:use-module (guix base32)
@@ -412,12 +413,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 ()