unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Maxime Devos <maximedevos@telenet.be>
To: "Arun Isaac" <arunisaac@systemreboot.net>,
	"Ludovic Courtès" <ludo@gnu.org>
Cc: Guix Devel <guix-devel@gnu.org>
Subject: Re: Move switch-symlinks to (guix build utils)
Date: Mon, 06 Jun 2022 14:20:51 +0200	[thread overview]
Message-ID: <6eca3fbfe370f650dfddd5eaf5fbe7193a80cd91.camel@telenet.be> (raw)
In-Reply-To: <87czfmm3pm.fsf@systemreboot.net>

[-- Attachment #1: Type: text/plain, Size: 995 bytes --]

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 #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 260 bytes --]

  reply	other threads:[~2022-06-06 12:22 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-01  7:34 Move switch-symlinks to (guix build utils) Arun Isaac
2022-06-01 12:09 ` Maxime Devos
2022-06-02 15:06   ` Arun Isaac
2022-06-02 15:13     ` Maxime Devos
2022-06-03 16:38       ` Ludovic Courtès
2022-06-03 17:09         ` Maxime Devos
2022-06-03 19:30           ` Ludovic Courtès
2022-06-03 19:30           ` Ludovic Courtès
2022-06-03 23:55             ` bokr
2022-06-04 10:17               ` Maxime Devos
2022-06-06 11:27           ` Arun Isaac
2022-06-06 12:20             ` Maxime Devos [this message]
2022-06-08 20:12               ` Arun Isaac

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6eca3fbfe370f650dfddd5eaf5fbe7193a80cd91.camel@telenet.be \
    --to=maximedevos@telenet.be \
    --cc=arunisaac@systemreboot.net \
    --cc=guix-devel@gnu.org \
    --cc=ludo@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).