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
1 changed files with 3 additions and 7 deletions

View File

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