home: symlink-manager: Avoid extra 'lstat' call.

* gnu/home/services/symlink-manager.scm (update-symlinks-script)[symlink-to-store?]:
Avoid extra 'lstat' call.
This commit is contained in:
Ludovic Courtès 2022-02-18 17:31:10 +01:00
parent a81bb1e4bb
commit a3a76a8384
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5

View file

@ -103,8 +103,13 @@ (define (get-backup-path path)
(string-append backup-dir "/." path))
(define (symlink-to-store? path)
(and (equal? (stat:type (lstat path)) 'symlink)
(store-file-name? (readlink path))))
(catch 'system-error
(lambda ()
(store-file-name? (readlink path)))
(lambda args
(if (= EINVAL (system-error-errno args))
#f
(apply throw args)))))
(define (backup-file path)
(mkdir-p backup-dir)