summaryrefslogtreecommitdiff
path: root/guix/discovery.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2017-06-18 00:02:56 +0200
committerLudovic Courtès <ludo@gnu.org>2017-06-18 00:14:07 +0200
commitd46c4423f46278bd2f96770ceb0667431414349e (patch)
tree60c92c81fa91db7b602ec7a6bdec8f6184b11e66 /guix/discovery.scm
parent3bacc655c5fd988f0199ef259adcb4fb3754042e (diff)
downloadgnu-guix-d46c4423f46278bd2f96770ceb0667431414349e.tar
gnu-guix-d46c4423f46278bd2f96770ceb0667431414349e.tar.gz
discovery: 'scheme-files' returns '() for a non-accessible directory.
Fixes a regression introduced in d27cc3bfaafe6b5b0831e88afb1c46311d382a0b. Reported by Ricardo Wurmus <rekado@elephly.net>. * guix/discovery.scm (scheme-files): Catch 'scandir*' system errors. Return '() and optionally raise a warning upon 'system-error'. * tests/discovery.scm ("scheme-modules, non-existent directory"): New test.
Diffstat (limited to 'guix/discovery.scm')
-rw-r--r--guix/discovery.scm13
1 files changed, 11 insertions, 2 deletions
diff --git a/guix/discovery.scm b/guix/discovery.scm
index 6cf8d6d566..292df2bd9c 100644
--- a/guix/discovery.scm
+++ b/guix/discovery.scm
@@ -38,7 +38,8 @@
(define* (scheme-files directory)
"Return the list of Scheme files found under DIRECTORY, recursively. The
-returned list is sorted in alphabetical order."
+returned list is sorted in alphabetical order. Return the empty list if
+DIRECTORY is not accessible."
(define (entry-type name properties)
(match (assoc-ref properties 'type)
('unknown
@@ -67,7 +68,15 @@ returned list is sorted in alphabetical order."
(else
result))))))
'()
- (scandir* directory)))
+ (catch 'system-error
+ (lambda ()
+ (scandir* directory))
+ (lambda args
+ (let ((errno (system-error-errno args)))
+ (unless (= errno ENOENT)
+ (warning (G_ "cannot access `~a': ~a~%")
+ directory (strerror errno)))
+ '())))))
(define file-name->module-name
(let ((not-slash (char-set-complement (char-set #\/))))