[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
01/20: store: Tolerate non-existent GC root directories.
From: |
guix-commits |
Subject: |
01/20: store: Tolerate non-existent GC root directories. |
Date: |
Sun, 4 Jun 2023 17:34:40 -0400 (EDT) |
civodul pushed a commit to branch wip-guix-index
in repository guix.
commit afbf85c312b4aafd965af4ed93b97c2eb273ba84
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Mon Mar 13 13:52:38 2023 +0100
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.
---
guix/store/roots.scm | 12 ++++++++++--
tests/store-roots.scm | 18 +++++++++++++++---
2 files changed, 25 insertions(+), 5 deletions(-)
diff --git a/guix/store/roots.scm b/guix/store/roots.scm
index 222f69c5c0..6b949b5a86 100644
--- a/guix/store/roots.scm
+++ b/guix/store/roots.scm
@@ -1,5 +1,5 @@
;;; 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.
;;;
@@ -105,7 +105,15 @@ are user-controlled symlinks stored anywhere on the file
system."
(map (match-lambda
((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))
(append (map canonical-root (filter symlink? files))
roots)
diff --git a/tests/store-roots.scm b/tests/store-roots.scm
index 5bcf1bc87e..9877987a65 100644
--- a/tests/store-roots.scm
+++ b/tests/store-roots.scm
@@ -1,5 +1,5 @@
;;; 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.
;;;
@@ -21,14 +21,26 @@
#:use-module (guix store)
#:use-module (guix store roots)
#: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-64))
-(define %store
- (open-connection))
+(define %store #f)
(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"
(let* ((item (add-text-to-store %store "something"
(random-text)))
- 07/20: squash! Don't insert directory if it's already present., (continued)
- 07/20: squash! Don't insert directory if it's already present., guix-commits, 2023/06/04
- 08/20: squash! Remove debugging statements., guix-commits, 2023/06/04
- 12/20: squash! Add one variant of each package (name/version pair)., guix-commits, 2023/06/04
- 13/20: squash! Create database when it doesn't already exist., guix-commits, 2023/06/04
- 16/20: squash! Simplify '--help'., guix-commits, 2023/06/04
- 18/20: squash! Optimize 'insert-package'., guix-commits, 2023/06/04
- 19/20: squash! Show output name except for "out"; remove '-d'., guix-commits, 2023/06/04
- 02/20: DRAFT Add 'guix index'., guix-commits, 2023/06/04
- 03/20: squash! Update test., guix-commits, 2023/06/04
- 05/20: squash! Improve error reporting and i18n., guix-commits, 2023/06/04
- 01/20: store: Tolerate non-existent GC root directories.,
guix-commits <=
- 06/20: squash! "with-method" -> "method", guix-commits, 2023/06/04
- 09/20: squash! Choose system-wide database if it's more recent., guix-commits, 2023/06/04
- 11/20: squash! Keep store prefix in database., guix-commits, 2023/06/04
- 15/20: squash! Rename to 'guix locate'., guix-commits, 2023/06/04
- 17/20: squash! Migrate schema when opening., guix-commits, 2023/06/04
- 20/20: squash! Document., guix-commits, 2023/06/04
- 10/20: squash! Do not insert the same directory more than once., guix-commits, 2023/06/04
- 14/20: squash! Remove actions; auto-update database when needed., guix-commits, 2023/06/04