[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
03/07: home: symlink-manager: Use no-follow version of file-exists?.
From: |
guix-commits |
Subject: |
03/07: home: symlink-manager: Use no-follow version of file-exists?. |
Date: |
Sat, 9 Apr 2022 18:18:25 -0400 (EDT) |
civodul pushed a commit to branch master
in repository guix.
commit d6b9a3faa8d470af6dada3e052a12bba6c32fc22
Author: Andrew Tropin <andrew@trop.in>
AuthorDate: Thu Apr 7 11:22:48 2022 +0300
home: symlink-manager: Use no-follow version of file-exists?.
* gnu/home/services/symlink-manager.scm (update-symlinks-script): Use
no-follow version of file-exists?.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
---
gnu/home/services/symlink-manager.scm | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/gnu/home/services/symlink-manager.scm
b/gnu/home/services/symlink-manager.scm
index 24d21bfad3..5b85a0e581 100644
--- a/gnu/home/services/symlink-manager.scm
+++ b/gnu/home/services/symlink-manager.scm
@@ -85,6 +85,10 @@ subdirectory from XDG_CONFIG_HOME to generate a target path."
;; such as "config/fontconfig/fonts.conf" or "bashrc".
(string-append home-directory "/" (preprocess-file file)))
+ (define (no-follow-file-exists? file)
+ "Return #t if file exists, even if it's a dangling symlink."
+ (->bool (false-if-exception (lstat file))))
+
(define (symlink-to-store? file)
(catch 'system-error
(lambda ()
@@ -123,7 +127,7 @@ subdirectory from XDG_CONFIG_HOME to generate a target
path."
(const #t)
(lambda (file stat _) ;leaf
(let ((file (target-file (strip file))))
- (when (file-exists? file)
+ (when (no-follow-file-exists? file)
;; DO NOT remove the file if it is no longer a symlink to
;; the store, it will be backed up later during
;; create-symlinks phase.
@@ -182,7 +186,7 @@ subdirectory from XDG_CONFIG_HOME to generate a target
path."
(lambda (file stat result) ;leaf
(let ((source (source-file (strip file)))
(target (target-file (strip file))))
- (when (file-exists? target)
+ (when (no-follow-file-exists? target)
(backup-file (strip file)))
(format #t (G_ "Symlinking ~a -> ~a...")
target source)
@@ -191,7 +195,7 @@ subdirectory from XDG_CONFIG_HOME to generate a target
path."
(lambda (directory stat result) ;down
(unless (string=? directory config-file-directory)
(let ((target (target-file (strip directory))))
- (when (and (file-exists? target)
+ (when (and (no-follow-file-exists? target)
(not (file-is-directory? target)))
(backup-file (strip directory)))
- branch master updated (975966ba09 -> d10cee7865), guix-commits, 2022/04/09
- 01/07: services: herd: Report whether a service is transient., guix-commits, 2022/04/09
- 04/07: gnu: efivar: Fix build errors on i686-linux., guix-commits, 2022/04/09
- 02/07: services: shepherd: Do not unload transient services., guix-commits, 2022/04/09
- 03/07: home: symlink-manager: Use no-follow version of file-exists?.,
guix-commits <=
- 05/07: doc: guix: Add missing article "a"., guix-commits, 2022/04/09
- 06/07: doc: package Reference: Mention syntax of package-description., guix-commits, 2022/04/09
- 07/07: gnu: strawberry: Update to 1.0.3., guix-commits, 2022/04/09