mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2025-01-26 04:29:25 -05:00
substitute-binary: Don't cache .narinfo lookups when lacking networking.
* guix/scripts/substitute-binary.scm (lookup-narinfo): Don't cache NARINFO when CACHE is #f.
This commit is contained in:
parent
bdbb6fbb19
commit
ae3b6bb0f4
1 changed files with 16 additions and 7 deletions
|
@ -236,8 +236,8 @@ (define (string->narinfo str)
|
||||||
(define (fetch-narinfo cache path)
|
(define (fetch-narinfo cache path)
|
||||||
"Return the <narinfo> record for PATH, or #f if CACHE does not hold PATH."
|
"Return the <narinfo> record for PATH, or #f if CACHE does not hold PATH."
|
||||||
(define (download url)
|
(define (download url)
|
||||||
;; Download the `nix-cache-info' from URL, and return its contents as an
|
;; Download the .narinfo from URL, and return its contents as a list of
|
||||||
;; list of key/value pairs.
|
;; key/value pairs.
|
||||||
(false-if-exception (fetch (string->uri url))))
|
(false-if-exception (fetch (string->uri url))))
|
||||||
|
|
||||||
(and (string=? (cache-store-directory cache) (%store-prefix))
|
(and (string=? (cache-store-directory cache) (%store-prefix))
|
||||||
|
@ -288,11 +288,15 @@ (define (cache-entry narinfo)
|
||||||
(values #f #f)))))
|
(values #f #f)))))
|
||||||
(if valid?
|
(if valid?
|
||||||
cached ; including negative caches
|
cached ; including negative caches
|
||||||
(let ((narinfo (and=> (force cache)
|
(let* ((cache (force cache))
|
||||||
(cut fetch-narinfo <> path))))
|
(narinfo (and cache (fetch-narinfo cache path))))
|
||||||
(with-atomic-file-output cache-file
|
;; Cache NARINFO only when CACHE was actually accessible. This
|
||||||
(lambda (out)
|
;; avoids caching negative hits when in fact we just lacked network
|
||||||
(write (cache-entry narinfo) out)))
|
;; access.
|
||||||
|
(when cache
|
||||||
|
(with-atomic-file-output cache-file
|
||||||
|
(lambda (out)
|
||||||
|
(write (cache-entry narinfo) out))))
|
||||||
narinfo))))
|
narinfo))))
|
||||||
|
|
||||||
(define (remove-expired-cached-narinfos)
|
(define (remove-expired-cached-narinfos)
|
||||||
|
@ -457,4 +461,9 @@ (define (guix-substitute-binary . args)
|
||||||
(("--version")
|
(("--version")
|
||||||
(show-version-and-exit "guix substitute-binary")))))
|
(show-version-and-exit "guix substitute-binary")))))
|
||||||
|
|
||||||
|
|
||||||
|
;;; Local Variable:
|
||||||
|
;;; eval: (put 'with-atomic-file-output 'scheme-indent-function 1)
|
||||||
|
;;; End:
|
||||||
|
|
||||||
;;; substitute-binary.scm ends here
|
;;; substitute-binary.scm ends here
|
||||||
|
|
Loading…
Reference in a new issue