diff options
author | Ludovic Courtès <ludo@gnu.org> | 2022-03-03 21:40:21 +0100 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2022-03-06 22:49:47 +0100 |
commit | a8d3033da61958c53c44dd5db90672bfc4533ef9 (patch) | |
tree | 62050d754601dd171ee44b5541bfaed31267230d /guix/import | |
parent | 8786c2e8d7585d4a55b1392093b9839f58bd4c3d (diff) |
import: github: Reuse HTTP connection for the /tags URL fallback.
* guix/import/github.scm (fetch-releases-or-tags): Call
'open-connection-for-uri' and reuse the same connection for the two
'http-fetch' calls.
* .dir-locals.el (scheme-mode): Add 'call-with-port'.
Diffstat (limited to 'guix/import')
-rw-r--r-- | guix/import/github.scm | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/guix/import/github.scm b/guix/import/github.scm index f3a1b1c5c4..51118d1d39 100644 --- a/guix/import/github.scm +++ b/guix/import/github.scm @@ -33,6 +33,7 @@ #:use-module ((guix ui) #:select (display-hint)) #:use-module ((guix download) #:prefix download:) #:use-module ((guix git-download) #:prefix download:) + #:autoload (guix build download) (open-connection-for-uri) #:use-module (guix import utils) #:use-module (json) #:use-module (guix packages) @@ -229,18 +230,23 @@ Alternatively, you can wait until your rate limit is reset, or use the (_ (raise c))))) - (let* ((port (http-fetch release-url #:headers headers)) - (result (json->scm port))) - (close-port port) - (match result - (#() - ;; We got the empty list, presumably because the user didn't use GitHub's - ;; "release" mechanism, but hopefully they did use Git tags. - (let* ((port (http-fetch tag-url #:headers headers)) - (json (json->scm port))) - (close-port port) - json)) - (x x)))))) + (let ((release-uri (string->uri release-url))) + (call-with-port (open-connection-for-uri release-uri) + (lambda (connection) + (let* ((result (json->scm + (http-fetch release-uri + #:port connection + #:keep-alive? #t + #:headers headers)))) + (match result + (#() + ;; We got the empty list, presumably because the user didn't use GitHub's + ;; "release" mechanism, but hopefully they did use Git tags. + (json->scm (http-fetch tag-url + #:port connection + #:keep-alive? #t + #:headers headers))) + (x x))))))))) (define (latest-released-version url package-name) "Return the newest released version and its tag given a string URL like |