GNU bug report logs - #47135
28.0.50; move to trash does not work if symlink is in Trash

Previous Next

Package: emacs;

Reported by: Jean Louis <bugs <at> gnu.support>

Date: Sun, 14 Mar 2021 09:10:02 UTC

Severity: minor

Tags: fixed

Found in version 28.0.50

Fixed in version 28.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


Message #8 received at 47135 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Jean Louis <bugs <at> gnu.support>
Cc: 47135 <at> debbugs.gnu.org
Subject: Re: bug#47135: 28.0.50; move to trash does not work if symlink is
 in Trash
Date: Thu, 18 Mar 2021 07:16:07 +0100
Jean Louis <bugs <at> gnu.support> writes:

> Here I have discovered condition when it does not work.
>
> In my trash there is this file:
>
>   lrwxrwxrwx 1  175 Jun 18  2019 Rock-and-Mineral-Identification.pdf -> /home/admin/Books/Geology/Rock-and-Mineral-Identification.pdf
>
> And then I have the directory, /home/admin/other/ where one can see this
> file:
>
> D -rw------- 1 5.6M Aug 13  2018 Rock-and-Mineral-Identification.pdf
>
> if I try to delete with x, I get this message:
>
> file-already-exists: File already exists:
> /home/data1/protected/tmp/Trash/Rock-and-Mineral-Identification.pdf

The problem is more general -- any file that exists already in the trash
directory leads to this problem.

To test:

touch /home/larsi/.local/share/Trash/files/foo
touch /tmp/foo

Then "d" the file in dired, and x, and then you'll get the error.
That's because the code in move-file-to-trash only checks whether the
.trashinfo file exists:

	       ;; Make a .trashinfo file.  Use O_EXCL, as per trash-spec 1.0.
	       (let* ((files-base (file-name-nondirectory fn))
		      (info-fn (expand-file-name
				(concat files-base ".trashinfo")
				trash-info-dir)))
		 (condition-case nil
		     (write-region nil nil info-fn nil 'quiet info-fn 'excl)
		   (file-already-exists
		    ;; Uniquify new-fn.  Some file managers do not
		    ;; like Emacs-style backup file names.  E.g.:
		    ;; https://bugs.kde.org/170956
		    (setq info-fn (make-temp-file
				   (expand-file-name files-base trash-info-dir)
				   nil ".trashinfo"))
		    (setq files-base (substring (file-name-nondirectory info-fn)
                                                0 (- (length ".trashinfo"))))

And then creates a new, unique name.  A .trashinfo file should exist, of
course, but here the Trash directory is out of sync, and Emacs should
handle that better, I guess.

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




This bug report was last modified 4 years and 117 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.