GNU bug report logs -
#60146
file-exists-in-trash-p needs better name or semantics
Previous Next
Reported by: Paul Eggert <eggert <at> cs.ucla.edu>
Date: Sat, 17 Dec 2022 05:18:01 UTC
Severity: normal
Done: Paul Eggert <eggert <at> cs.ucla.edu>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 60146 in the body.
You can then email your comments to 60146 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#60146
; Package
emacs
.
(Sat, 17 Dec 2022 05:18:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Paul Eggert <eggert <at> cs.ucla.edu>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Sat, 17 Dec 2022 05:18:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
The recently-added function (file-exists-in-trash-p FILE) is poorly
named since it's not really related to trash - it's simply checking for
the existence of a directory entry named FILE.
How about extending file-exists-p instead? (file-exists-p FILE t) would
be like (file-exists-p FILE) except it would not follow symlinks. This
extension can be implemented via a single system call on POSIX systems,
and this would be more efficient and would avoid a race in the current
implementation of file-exists-in-trash-p. (Though of course pretty much
any use of this new function makes one vulnerable to races....)
If extending file-exists-p is too much, at least please rename
file-exists-in-trash-p to something like files--exists-nofollow-p, to
indicate that it's private to files.el and to say better what it means.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#60146
; Package
emacs
.
(Sat, 17 Dec 2022 08:48:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 60146 <at> debbugs.gnu.org (full text, mbox):
> Date: Fri, 16 Dec 2022 21:17:13 -0800
> From: Paul Eggert <eggert <at> cs.ucla.edu>
>
> The recently-added function (file-exists-in-trash-p FILE) is poorly
> named since it's not really related to trash - it's simply checking for
> the existence of a directory entry named FILE.
>
> How about extending file-exists-p instead? (file-exists-p FILE t) would
> be like (file-exists-p FILE) except it would not follow symlinks. This
> extension can be implemented via a single system call on POSIX systems,
> and this would be more efficient and would avoid a race in the current
> implementation of file-exists-in-trash-p. (Though of course pretty much
> any use of this new function makes one vulnerable to races....)
>
> If extending file-exists-p is too much, at least please rename
> file-exists-in-trash-p to something like files--exists-nofollow-p, to
> indicate that it's private to files.el and to say better what it means.
I don't really mind renaming that function, but the reason I called it
like I did was that apparently no one needed such a functionality in
Emacs until now, except in this obscure use case of moving to trash.
That seems to tell me that extending file-exists-p would be a solution
waiting for the problem, something that we don't like doing.
In any case, if we do decide to extend file-exists-p, it would need to
be done on master, as that is not a trivial change, which has to be
done in C.
Lars, Stefan, WDYT?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#60146
; Package
emacs
.
(Sat, 17 Dec 2022 10:02:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 60146 <at> debbugs.gnu.org (full text, mbox):
Paul Eggert <eggert <at> cs.ucla.edu> writes:
Hi Paul,
> How about extending file-exists-p instead? (file-exists-p FILE t)
> would be like (file-exists-p FILE) except it would not follow
> symlinks. This extension can be implemented via a single system call
> on POSIX systems, and this would be more efficient and would avoid a
> race in the current implementation of file-exists-in-trash-p. (Though
> of course pretty much any use of this new function makes one
> vulnerable to races....)
Pls don't do it in the emacs-29 branch. file-exists-p checks for file
name handlers, with all consequences for a changed signature.
Best regards, Michael.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#60146
; Package
emacs
.
(Sat, 17 Dec 2022 15:52:01 GMT)
Full text and
rfc822 format available.
Message #14 received at 60146 <at> debbugs.gnu.org (full text, mbox):
> I don't really mind renaming that function, but the reason I called it
> like I did was that apparently no one needed such a functionality in
> Emacs until now, except in this obscure use case of moving to trash.
> That seems to tell me that extending file-exists-p would be a solution
> waiting for the problem, something that we don't like doing.
Hmm... arguing about names, eh?
Let me throw that hat into the ring: IIUC this is a variant of
`file-exists-p` (currently) used only when dealing the trash, so I'd
call it `trash--file-exists-p`.
> In any case, if we do decide to extend file-exists-p, it would need to
> be done on master, as that is not a trivial change, which has to be
> done in C.
Indeed, I see no need for that on emacs-29.
Stefan
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#60146
; Package
emacs
.
(Sat, 17 Dec 2022 17:46:02 GMT)
Full text and
rfc822 format available.
Message #17 received at 60146 <at> debbugs.gnu.org (full text, mbox):
> From: Stefan Monnier <monnier <at> iro.umontreal.ca>
> Cc: Paul Eggert <eggert <at> cs.ucla.edu>, Lars Ingebrigtsen <larsi <at> gnus.org>,
> 60146 <at> debbugs.gnu.org
> Date: Sat, 17 Dec 2022 10:51:38 -0500
>
> Let me throw that hat into the ring: IIUC this is a variant of
> `file-exists-p` (currently) used only when dealing the trash, so I'd
> call it `trash--file-exists-p`.
Well, the function is defined in files.el, so starting the name with
"trash" would be frowned upon...
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#60146
; Package
emacs
.
(Sat, 17 Dec 2022 19:58:02 GMT)
Full text and
rfc822 format available.
Message #20 received at 60146 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On 12/17/22 00:47, Eli Zaretskii wrote:
> I don't really mind renaming that function, but the reason I called it
> like I did was that apparently no one needed such a functionality in
> Emacs until now,
I have a bit of a different take. First, there's adequate functionality
in Emacs now if we don't mind inefficiency, and it's already used; just
call file-attributes. (Gnus does this, in nnmaildir-unlink at least, and
I expect there are other uses.) Second, I wouldn't be surprised if other
uses of file-exists-p have problems similar to the one you found in
move-file-to-trash. Not that any of us have time to go scout for them
right now.
It's a minor point. Still, the name file-exists-in-trash-p really needs
to go somehow as it's not a name that should be user-visible. How about
the attached patch?
[0001-Remove-file-exists-in-trash-p.patch (text/x-patch, attachment)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#60146
; Package
emacs
.
(Sat, 17 Dec 2022 20:10:01 GMT)
Full text and
rfc822 format available.
Message #23 received at 60146 <at> debbugs.gnu.org (full text, mbox):
> Date: Sat, 17 Dec 2022 11:57:39 -0800
> Cc: 60146 <at> debbugs.gnu.org
> From: Paul Eggert <eggert <at> cs.ucla.edu>
>
> I have a bit of a different take. First, there's adequate functionality
> in Emacs now if we don't mind inefficiency, and it's already used; just
> call file-attributes. (Gnus does this, in nnmaildir-unlink at least, and
> I expect there are other uses.) Second, I wouldn't be surprised if other
> uses of file-exists-p have problems similar to the one you found in
> move-file-to-trash. Not that any of us have time to go scout for them
> right now.
>
> It's a minor point. Still, the name file-exists-in-trash-p really needs
> to go somehow as it's not a name that should be user-visible. How about
> the attached patch?
If you can verify that it works in the scenario of bug#59986, I'm okay
with this change.
Reply sent
to
Paul Eggert <eggert <at> cs.ucla.edu>
:
You have taken responsibility.
(Sat, 17 Dec 2022 23:56:01 GMT)
Full text and
rfc822 format available.
Notification sent
to
Paul Eggert <eggert <at> cs.ucla.edu>
:
bug acknowledged by developer.
(Sat, 17 Dec 2022 23:56:02 GMT)
Full text and
rfc822 format available.
Message #28 received at 60146-done <at> debbugs.gnu.org (full text, mbox):
On 12/17/22 12:09, Eli Zaretskii wrote:
> If you can verify that it works in the scenario of bug#59986, I'm okay
> with this change.
Thanks, I checked that the patch works in that scenario (dangling
symlink in the trash directory), and installed it. Closing the bug report.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Sun, 15 Jan 2023 12:24:06 GMT)
Full text and
rfc822 format available.
This bug report was last modified 2 years and 158 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.