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

From: Gustavo Barros <[email-masked]>
Date: Thu, 27 Oct 2022 14:51:39 -0300

On Thu, 27 Oct 2022 at 14:30, Eli Zaretskii <[email-masked]> wrote:

> And the directory by that name really already exists under Trash?
> That would mean something is wrong with make-temp-file on your system,
> because it's supposed to return a different file name.  You will see
> that move-file-to-trash calls make-temp-file near its end.

Well, not like this. It existed because Emacs created it. Indeed, a
Trash should be able to receive multiple files of the same name, and
they must be uniquified somehow, and that's what Emacs is doing by
appending a suffix to the file name.

But, to be clear on the process. Before starting things, I cleared my
Trash, so that "~/.local/share/Trash/files" is empty.

I clone the repo, and move it to trash with (move-file-to-trash
"/path/to/org-mode").

Now "~/.local/share/Trash/files" contains "org-mode", with proper
contents, as expected.

I clone again and move to trash again with (move-file-to-trash
"/path/to/org-mode"). Now it fails with "(file-already-exists "File
exists" "/home/<username>/.local/share/Trash/files/org-mode7AV...")",
and "~/.local/share/Trash/files" contains:

    org-mode
    org-mode7AVOuq

Where "org-mode7AVOuq" is empty. And "org-mode", with contents, is
still in "/path/to/org-mode".

> (I cannot myself try reproducing this because I don't have access to a
> system with freedesktop.org-style Trash.)

Understood, I'm at your disposal to send any information and perform
any tests you need.