Subject: bug#44217: bug#44216: 28.0.50; Incorret during delete in Tramp: Trashing...done

From: Lars Ingebrigtsen <[email-masked]>
Date: Mon, 26 Oct 2020 14:17:33 +0100

Michael Albinus <[email-masked]> writes:

> How did you delete the file? You must give the optional argument TRASH a
> non-nil value, as in
>
> (delete-file "/ssh:other-host:/tmp/file" t)

In dired, which basically does that.

>> Shouldn't Tramp then move the file to `trash-directory' instead of
>> giving up and just deleting the file?
>
> Why that? `trash-directory' is defined as target for
> `move_file_to_trash'; it has nothing to do with deleting of remote
> files.

It doesn't now, but that's only because it's implemented that way.

> And it would be a security flaw, if remote files would be moved
> to the local "~/Trash" directory.

Well...  no, not more than usual.  You can delete a non-Tramp file from
an encrypted file system, and have the Trash on a non-encrypted file
system, and that would be the same flaw.  Whether Tramp is involved or
not is orthogonal.  (Except as an efficiency thing.)

>> If this is working as designed, it should at least be mentioned in the
>> doc string(s) and the manual.
>
> I believe it is mentioned. See the docstrings of `trash-directory' and
> `move-file-to-trash'. Well, the latter might explicitly state that it is
> not intended for remote files, but this is another game.

Neither doc string says anything about remote files?

---

Directory for ‘move-file-to-trash’ to move files and directories to.
This directory is used only when the function ‘system-move-file-to-trash’
is not defined.
Relative paths are interpreted relative to ‘default-directory’.
If the value is nil, Emacs uses a freedesktop.org-style trashcan.

---

Move the file (or directory) named FILENAME to the trash.
When ‘delete-by-moving-to-trash’ is non-nil, this function is
called by ‘delete-file’ and ‘delete-directory’ instead of
deleting files outright.

If the function ‘system-move-file-to-trash’ is defined, call it
 with FILENAME as an argument.
Otherwise, if ‘trash-directory’ is non-nil, move FILENAME to that
 directory.
Otherwise, trash FILENAME using the freedesktop.org conventions,
 like the GNOME, KDE and XFCE desktop environments.  Emacs moves
 files only to "home trash", ignoring per-volume trashcans.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no