From 59d2b8aa23d0119a3c95e9d3b90fd6b36d1bde6a Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Wed, 16 Oct 2024 11:00:24 +0100 Subject: Wrap more with call-with-cached-connection To close the connection in case of errors. --- nar-herder/storage.scm | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/nar-herder/storage.scm b/nar-herder/storage.scm index 57f35fb..87e2ff1 100644 --- a/nar-herder/storage.scm +++ b/nar-herder/storage.scm @@ -424,22 +424,21 @@ When VERIFY-CERTIFICATE? is true, verify HTTPS server certificates." (lambda () (retry-on-error (lambda () - (call-with-values - (lambda () - (call-with-cached-connection - uri - (lambda (port) - (http-get uri - #:port port - #:decode-body? #f - #:keep-alive? #t - #:streaming? #t)))) - (lambda (response body) - (and (= (response-code response) - 200) - (let ((json-body (json->scm body))) - (eq? (assoc-ref json-body "stored") - #t)))))) + (call-with-cached-connection + uri + (lambda (port) + (let ((response + body + (http-get uri + #:port port + #:decode-body? #f + #:keep-alive? #t + #:streaming? #t))) + (and (= (response-code response) + 200) + (let ((json-body (json->scm body))) + (eq? (assoc-ref json-body "stored") + #t))))))) #:times 3 #:delay 5)) #:timeout 30))))) -- cgit v1.2.3