unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Lars Ingebrigtsen <larsi@gnus.org>
To: Jean Louis <bugs@gnu.support>
Cc: 47135@debbugs.gnu.org
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	[thread overview]
Message-ID: <87o8fhrnq0.fsf@gnus.org> (raw)
In-Reply-To: <86im5udrz6.fsf@protected.rcdrun.com> (Jean Louis's message of "Sun, 14 Mar 2021 12:06:37 +0300")

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	other threads:[~2021-03-18  6:16 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-14  9:06 bug#47135: 28.0.50; move to trash does not work if symlink is in Trash Jean Louis
2021-03-18  6:16 ` Lars Ingebrigtsen [this message]
2021-03-18  6:36   ` Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87o8fhrnq0.fsf@gnus.org \
    --to=larsi@gnus.org \
    --cc=47135@debbugs.gnu.org \
    --cc=bugs@gnu.support \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).