store: Tolerate non-existent GC root directories.
* guix/store/roots.scm (gc-roots): Wrap 'scandir*' call in 'catch'. * tests/store-roots.scm ("gc-roots, initial"): New test. Move 'open-connection' call below.master
parent
81231bf236
commit
1261ce1523
|
@ -1,5 +1,5 @@
|
||||||
;;; GNU Guix --- Functional package management for GNU
|
;;; GNU Guix --- Functional package management for GNU
|
||||||
;;; Copyright © 2012, 2013, 2014, 2017, 2019 Ludovic Courtès <ludo@gnu.org>
|
;;; Copyright © 2012-2014, 2017, 2019, 2023 Ludovic Courtès <ludo@gnu.org>
|
||||||
;;;
|
;;;
|
||||||
;;; This file is part of GNU Guix.
|
;;; This file is part of GNU Guix.
|
||||||
;;;
|
;;;
|
||||||
|
@ -105,7 +105,15 @@ are user-controlled symlinks stored anywhere on the file system."
|
||||||
(map (match-lambda
|
(map (match-lambda
|
||||||
((file . properties)
|
((file . properties)
|
||||||
(cons (scope file) properties)))
|
(cons (scope file) properties)))
|
||||||
(scandir* directory regular?)))))
|
(catch 'system-error
|
||||||
|
(lambda ()
|
||||||
|
(scandir* directory regular?))
|
||||||
|
(lambda args
|
||||||
|
(if (= ENOENT
|
||||||
|
(system-error-errno
|
||||||
|
args))
|
||||||
|
'()
|
||||||
|
(apply throw args))))))))
|
||||||
(loop (append rest (map first sub-directories))
|
(loop (append rest (map first sub-directories))
|
||||||
(append (map canonical-root (filter symlink? files))
|
(append (map canonical-root (filter symlink? files))
|
||||||
roots)
|
roots)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
;;; GNU Guix --- Functional package management for GNU
|
;;; GNU Guix --- Functional package management for GNU
|
||||||
;;; Copyright © 2019 Ludovic Courtès <ludo@gnu.org>
|
;;; Copyright © 2019, 2023 Ludovic Courtès <ludo@gnu.org>
|
||||||
;;;
|
;;;
|
||||||
;;; This file is part of GNU Guix.
|
;;; This file is part of GNU Guix.
|
||||||
;;;
|
;;;
|
||||||
|
@ -21,14 +21,26 @@
|
||||||
#:use-module (guix store)
|
#:use-module (guix store)
|
||||||
#:use-module (guix store roots)
|
#:use-module (guix store roots)
|
||||||
#:use-module ((guix utils) #:select (call-with-temporary-directory))
|
#:use-module ((guix utils) #:select (call-with-temporary-directory))
|
||||||
|
#:use-module ((guix build utils) #:select (delete-file-recursively))
|
||||||
|
#:use-module ((guix config) #:select (%state-directory))
|
||||||
#:use-module (srfi srfi-1)
|
#:use-module (srfi srfi-1)
|
||||||
#:use-module (srfi srfi-64))
|
#:use-module (srfi srfi-64))
|
||||||
|
|
||||||
(define %store
|
(define %store #f)
|
||||||
(open-connection))
|
|
||||||
|
|
||||||
(test-begin "store-roots")
|
(test-begin "store-roots")
|
||||||
|
|
||||||
|
(test-equal "gc-roots, initial"
|
||||||
|
(list (string-append %state-directory "/profiles"))
|
||||||
|
(begin
|
||||||
|
;; 'gc-roots' should gracefully handle lack of that directory.
|
||||||
|
(delete-file-recursively (string-append %state-directory "/profiles"))
|
||||||
|
(gc-roots)))
|
||||||
|
|
||||||
|
;; The 'open-connection' call below gets guix-daemon to create
|
||||||
|
;; %STATE-DIRECTORY/profiles.
|
||||||
|
(set! %store (open-connection))
|
||||||
|
|
||||||
(test-assert "gc-roots, regular root"
|
(test-assert "gc-roots, regular root"
|
||||||
(let* ((item (add-text-to-store %store "something"
|
(let* ((item (add-text-to-store %store "something"
|
||||||
(random-text)))
|
(random-text)))
|
||||||
|
|
Reference in New Issue