Archived
1
0
Fork 0

inferior: Use a safe symlink monadic procedure.

This is a follow-up of 6ee7e3d26b.

* guix/inferior.scm (cached-channel-instance): Introduce "symlink/safe" and
use it instead of symlink. Remove the duplicated "file-exists?" call.
This commit is contained in:
Mathieu Othacehe 2021-03-10 12:08:10 +01:00
parent 8898eaec57
commit a831ff6bc3
No known key found for this signature in database
GPG key ID: 8354763531769CA6

View file

@ -740,8 +740,16 @@ determines whether CHANNELS are authenticated."
(string-append directory "/" file)) (string-append directory "/" file))
(scandir directory base32-encoded-sha256?))) (scandir directory base32-encoded-sha256?)))
(define (symlink/safe old new)
(catch 'system-error
(lambda ()
(symlink old new))
(lambda args
(unless (= EEXIST (system-error-errno args))
(apply throw args)))))
(define symlink* (define symlink*
(lift2 symlink %store-monad)) (lift2 symlink/safe %store-monad))
(define add-indirect-root* (define add-indirect-root*
(store-lift add-indirect-root)) (store-lift add-indirect-root))
@ -766,9 +774,8 @@ determines whether CHANNELS are authenticated."
(built-derivations (list profile)) (built-derivations (list profile))
;; Note: Caching is fine even when AUTHENTICATE? is false because ;; Note: Caching is fine even when AUTHENTICATE? is false because
;; we always call 'latest-channel-instances?'. ;; we always call 'latest-channel-instances?'.
(unless (file-exists? cached) (symlink* (derivation->output-path profile) cached)
(symlink* (derivation->output-path profile) cached) (add-indirect-root* cached)
(add-indirect-root* cached))
(return cached)))))) (return cached))))))
(define* (inferior-for-channels channels (define* (inferior-for-channels channels