Andrew Tropin wrote 3 years ago
(address . guix-patches@gnu.org)
* gnu/home/services/symlink-manager.scm (update-symlinks-script): Use
no-follow version of file-exists?.
---
file-exists? returns #f on dangling symlinks, which makes such files
"invisible" during the cleanup process and breaks activation of home
environment.
gnu/home/services/symlink-manager.scm | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
Toggle diff (47 lines)
diff --git a/gnu/home/services/symlink-manager.scm b/gnu/home/services/symlink-manager.scm
index 6d19258ec7..bb67152e5b 100644
--- a/gnu/home/services/symlink-manager.scm
+++ b/gnu/home/services/symlink-manager.scm
@@ -85,6 +85,13 @@ (define (target-file file)
;; 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."
+ (or (file-exists? file)
+ (and=> (false-if-exception (lstat file))
+ (lambda (x)
+ (equal? (stat:type x) 'symlink)))))
+
(define (symlink-to-store? file)
(catch 'system-error
(lambda ()
@@ -123,7 +130,7 @@ (define (strip file)
(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.
@@ -183,7 +190,7 @@ (define (source-file file)
(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)
@@ -192,7 +199,7 @@ (define (source-file file)
(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)))
--
2.34.0
-----BEGIN PGP SIGNATURE-----
iQJDBAEBCgAtFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmJOqdQPHGFuZHJld0B0
cm9wLmluAAoJECII0glYwd6wWssP/R3DnmjRX8tROgJDGXixms/N0MahKWhSIAXG
mIxhPmqeYT22RjXDQWxuAK7d0nBWY9CD6yNocQeQ6lBZ5lyiiow+GAqUYqj+vQLO
RWLbuk+1+prUbGDE8OyXO0nVAFv8f7PYVb6P5shL0m4qIfONcwGI70NAW8wx3FaP
1RvzsbZLlNwHRfquB63OV7oi7w7Ku93sJGoIBZpOPD1ezTFi6Es9m60DEDSoNu9y
v6SiQdmMpPa9mljJa6iIT3uYy5x9X3wd1FDvN1nl9ioxFv6l6RQLyg8NQu7cZlOu
AsbA8u3XN9PlTCKRkQPyLAQhhy9oLIA4QILa5z6rI28Y8CX9GcLtn2HrPXGw9y3W
li9YATvZ/27u9f3lpmmviP+1qHLJYE+3byqfiNLWgry7JD1xIs8NWtWJmOdfyk1w
6hJEkr+B1a7rj0AzmQ2yet7BwDUZ9iVTDZnOo66CDeM4EWX5Z6Byx5/83CK/uTok
+dwFzI0/tdTzNUagScGJwPssRz8w3u0U71sG9mGWmyWkjZt/RhKzaEN3dowvBixU
24B+2cnzos/rEE0CWKAJ8X6L/c6YIbkVO5O/mzYxWSluYri7selClDAXbqOCDfS3
+gD6SDsPA6fDzsfb7AtTTPCXxxKS4Z4ODk5FdxwRBteDzEJxBL1NDiyd8hPJwpv3
p0RRM2D5
=cHw6
-----END PGP SIGNATURE-----