aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2013-04-15 23:42:42 +0200
committerLudovic Courtès <ludo@gnu.org>2013-04-15 23:43:10 +0200
commit0c357a088bb0b267df9d9bde486e6603f66cd029 (patch)
tree9d03dcc8fa79bcdaca430ad3e20ffd833972c411
parenteba783b7b20cbf84dfd0a04bc19e3bebbc9a30fc (diff)
downloadpatches-0c357a088bb0b267df9d9bde486e6603f66cd029.tar
patches-0c357a088bb0b267df9d9bde486e6603f66cd029.tar.gz
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'.
-rwxr-xr-xguix/scripts/substitute-binary.scm7
1 files changed, 4 insertions, 3 deletions
diff --git a/guix/scripts/substitute-binary.scm b/guix/scripts/substitute-binary.scm
index 453a29a5ea..94cfac8bcc 100755
--- a/guix/scripts/substitute-binary.scm
+++ b/guix/scripts/substitute-binary.scm
@@ -306,7 +306,8 @@ check what it has."
(values #f #f)))))
(if valid?
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
(lambda (out)
(write (cache-entry narinfo) out)))
@@ -351,7 +352,7 @@ through COMMAND. INPUT must be a file input port."
(mkdir-p %narinfo-cache-directory)
(match args
(("--query")
- (let ((cache (open-cache %cache-url)))
+ (let ((cache (delay (open-cache %cache-url))))
(let loop ((command (read-line)))
(or (eof-object? command)
(begin
@@ -397,7 +398,7 @@ through COMMAND. INPUT must be a file input port."
(loop (read-line)))))))
(("--substitute" store-path 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))
(uri (narinfo-uri narinfo)))
;; Tell the daemon what the expected hash of the Nar itself is.