Subject: Re: bug#58721: 28.2; dired with delete-by-moving-to-trash can't trash directory twice

From: Eli Zaretskii <[email-masked]>
Date: Thu, 27 Oct 2022 19:09:17 +0300

> From: Gustavo Barros <[email-masked]>
> Date: Sat, 22 Oct 2022 15:23:15 -0300
> 
> If one enables `delete-by-moving-to-trash' and tries to delete a
> directory with the same name twice from dired, dired won't let one do
> so, resulting in "file-already-exists: File exists: </path/>" error
> instead.
> 
> Start with `emacs -Q'.  Set:
> 
>     (setq delete-by-moving-to-trash t)
> 
> Open dired at "/tmp/" (or some other place of your choosing).  Clone
> the org repository there with `M-& git clone
> https://git.savannah.gnu.org/git/emacs/org-mode.git RET' (a comment on
> why this below), refresh with `g', navigate to the corresponding
> directory, and trash it with `D', confirm.  The operation succeeds.
> 
> Now, repeat it. Clone the repository and delete the directory again. I
> get here "file-already-exists: File exists:
> /home/<username>/.local/share/Trash/files/org-moderiQJ08", and the
> directory is not trashed.
> 
> Of course, this has nothing to do with Org.  But I've tried to create
> a simple file with `touch' or an empty directory with `mkdir' and the
> issue does not arise then.  And I haven't figured out what is the
> difference in the `org-mode' directory which triggers the problem, it
> just happens to be the last failing case of an issue which happens
> occasionally here.

Could you please set debug-on-error t, repeat the experiment, and post
the Lisp backtrace from the error?

Thanks.