summaryrefslogtreecommitdiff
path: root/guix/scripts/discover.scm
diff options
context:
space:
mode:
authorMathieu Othacehe <othacehe@gnu.org>2020-12-05 10:37:01 +0100
committerMathieu Othacehe <othacehe@gnu.org>2020-12-05 10:38:52 +0100
commitc952a9312a94bb236495ec654bf184685cf9fe79 (patch)
treef9f82744a1e8d13979a7ed8170a6015303dc89c1 /guix/scripts/discover.scm
parent4cf3734c56d669ee2d78082e5d7c4d0a58e0f800 (diff)
downloadguix-patches-c952a9312a94bb236495ec654bf184685cf9fe79.tar
guix-patches-c952a9312a94bb236495ec654bf184685cf9fe79.tar.gz
scripts: discover: Check for cache file existence.
Fixes: https://issues.guix.gnu.org/45045. * guix/scripts/discover.scm (read-substitute-urls): Check for file existence.
Diffstat (limited to 'guix/scripts/discover.scm')
-rw-r--r--guix/scripts/discover.scm22
1 files changed, 14 insertions, 8 deletions
diff --git a/guix/scripts/discover.scm b/guix/scripts/discover.scm
index b17dbdcb3c..007db0d49d 100644
--- a/guix/scripts/discover.scm
+++ b/guix/scripts/discover.scm
@@ -110,14 +110,16 @@ lock on FILE to synchronize with any potential readers."
(define* (read-substitute-urls #:key (file (%publish-file)))
"Read substitute urls list from FILE and return it. Use a read lock on FILE
to synchronize with the writer."
- (with-read-file-lock file
- (call-with-input-file file
- (lambda (port)
- (let loop ((url (read-line port))
- (urls '()))
- (if (eof-object? url)
- urls
- (loop (read-line port) (cons url urls))))))))
+ (if (file-exists? file)
+ (with-read-file-lock file
+ (call-with-input-file file
+ (lambda (port)
+ (let loop ((url (read-line port))
+ (urls '()))
+ (if (eof-object? url)
+ urls
+ (loop (read-line port) (cons url urls)))))))
+ '()))
;;;
@@ -156,3 +158,7 @@ to synchronize with the writer."
(mkdir-p (dirname publish-file))
(avahi-browse-service-thread service-proc
#:types %services)))))
+
+;;; Local Variables:
+;;; eval: (put 'with-read-file-lock 'scheme-indent-function 1)
+;;; End: