bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#47135: 28.0.50; move to trash does not work if symlink is in Trash


From: Lars Ingebrigtsen
Subject: 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
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Jean Louis <bugs@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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]