2
0
Fork 0
mirror of git://git.savannah.gnu.org/guix/guix-cuirass.git synced 2023-12-14 06:03:04 +01:00

http: Really gracefully handle missing file on /download.

This is a followup to 103a6ec27b.

* src/cuirass/http.scm (url-handler): Remove ‘catch 'system-error’ for
“/download” handler since ‘respond-file’ cannot possibly throw to
'system-error.  Add explicit ‘file-exists?’ call instead.
This commit is contained in:
Ludovic Courtès 2023-10-12 23:14:13 +02:00
parent db6b633711
commit 93e27ff07c
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5

View file

@ -1247,13 +1247,9 @@ passed, only display JOBS targeting this SYSTEM."
(respond-json-with-error (respond-json-with-error
code "Could not find the requested build product.")))) code "Could not find the requested build product."))))
(if file (if file
(catch 'system-error (if (file-exists? file)
(lambda () (respond-file file #:ttl %static-file-ttl)
(respond-file file #:ttl %static-file-ttl)) (fail 500)) ;something's wrong: it vanished
(lambda args
(if (= ENOENT (system-error-errno args))
(fail 500) ;something's wrong: it vanished
(apply throw args))))
(fail 404)))) ;no such build product (fail 404)))) ;no such build product
(('GET "machine" name) (('GET "machine" name)