substitute-binary: Call `open-cache' only when needed.

* guix/scripts/substitute-binary.scm (lookup-narinfo): Force CACHE when
  passing it to `fetch-narinfo'.
  (guix-substitute-binary): Delay calls to `open-cache'.
This commit is contained in:
Ludovic Courtès 2013-04-15 23:42:42 +02:00
parent eba783b7b2
commit 0c357a088b
1 changed files with 4 additions and 3 deletions

View File

@ -306,7 +306,8 @@ check what it has."
(values #f #f))))) (values #f #f)))))
(if valid? (if valid?
cached ; including negative caches cached ; including negative caches
(let ((narinfo (fetch-narinfo cache path))) (let ((narinfo (and=> (force cache)
(cut fetch-narinfo <> path))))
(with-atomic-file-output cache-file (with-atomic-file-output cache-file
(lambda (out) (lambda (out)
(write (cache-entry narinfo) out))) (write (cache-entry narinfo) out)))
@ -351,7 +352,7 @@ through COMMAND. INPUT must be a file input port."
(mkdir-p %narinfo-cache-directory) (mkdir-p %narinfo-cache-directory)
(match args (match args
(("--query") (("--query")
(let ((cache (open-cache %cache-url))) (let ((cache (delay (open-cache %cache-url))))
(let loop ((command (read-line))) (let loop ((command (read-line)))
(or (eof-object? command) (or (eof-object? command)
(begin (begin
@ -397,7 +398,7 @@ through COMMAND. INPUT must be a file input port."
(loop (read-line))))))) (loop (read-line)))))))
(("--substitute" store-path destination) (("--substitute" store-path destination)
;; Download STORE-PATH and add store it as a Nar in file DESTINATION. ;; Download STORE-PATH and add store it as a Nar in file DESTINATION.
(let* ((cache (open-cache %cache-url)) (let* ((cache (delay (open-cache %cache-url)))
(narinfo (lookup-narinfo cache store-path)) (narinfo (lookup-narinfo cache store-path))
(uri (narinfo-uri narinfo))) (uri (narinfo-uri narinfo)))
;; Tell the daemon what the expected hash of the Nar itself is. ;; Tell the daemon what the expected hash of the Nar itself is.