guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Move switch-symlinks to (guix build utils)


From: Maxime Devos
Subject: Re: Move switch-symlinks to (guix build utils)
Date: Mon, 06 Jun 2022 14:20:51 +0200
User-agent: Evolution 3.38.3-1

Arun Isaac schreef op ma 06-06-2022 om 16:57 [+0530]:
> Could we implement symlink/remove-old without catch and throw? Something
> like:
> 
> --8<---------------cut here---------------start------------->8---
> (define (symlink/remove-old target link)
>   "Make a symbolic link named LINK pointing to TARGET. If LINK already
> exists, it will be removed first.  This is not an atomic operation."
>   (when (file-exists? link)
>     (delete-file link))
>   (symlink target link))
> --8<---------------cut here---------------end--------------->8---

file-exists? does not check if the file exists -- for a broken symlink,
it will return #false instead of #true.

Also, this introduces additional non-atomicity (though in this
particular case, this does not seem to be a problem).  It would also
make things a tiny bit slower, because file-exists? makes an additional
syscall.

For these three reasons, I would go for the more robust catch+throw.

Greetings,
Maxime.

Attachment: signature.asc
Description: This is a digitally signed message part


reply via email to

[Prev in Thread] Current Thread [Next in Thread]