branch: master
commit 93e27ff07c2afaf088c0333995b23bb08fbb51b6
Author: Ludovic Courtès <[email protected]>
AuthorDate: Thu Oct 12 23:14:13 2023 +0200

    http: Really gracefully handle missing file on /download.
    
    This is a followup to 103a6ec27b42346f942cb5ff7c2398ca9340a58e.
    
    * 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.
---
 src/cuirass/http.scm | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/src/cuirass/http.scm b/src/cuirass/http.scm
index 9c4c723..fd9bb0c 100644
--- a/src/cuirass/http.scm
+++ b/src/cuirass/http.scm
@@ -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)

Reply via email to