From 93e27ff07c2afaf088c0333995b23bb08fbb51b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Thu, 12 Oct 2023 23:14:13 +0200 Subject: [PATCH] http: Really gracefully handle missing file on /download. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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)