unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: mail--- via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: 48280@debbugs.gnu.org
Subject: bug#48280: 28.0.50; Fix moving directories with the same name to trash
Date: Fri, 07 May 2021 19:31:23 +0000	[thread overview]
Message-ID: <6ae67348-9c12-ba4c-318a-5d6b50cfd92c@codrut.pro> (raw)

[-- Attachment #1: Type: text/plain, Size: 1056 bytes --]

Hello,

I've attached a patch for this bug I was dealing with while trying out
28.0.50 commit a2842a11728336fc8110eedb5176ecfbe71bbc79.

Refs: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=47135
<https://debbugs.gnu.org/cgi/bugreport.cgi?bug=47135>

To reproduce, save this to a `bug.el` file:

```elisp

(setq delete-by-moving-to-trash t)

(let ((test-dir "~/test123"))
   (progn
     (message "Creating directory: 1")
     (make-directory test-dir)
     (message "Deleting directory: 1")
     (delete-directory test-dir t t)

     (message "Creating directory: 2")
     (make-directory test-dir)
     (message "Deleting directory: 2")
     (delete-directory test-dir t t)

     (message "Success!")))
```

And execute with: `emacs -nw -Q -l ./bug.el`.

Expected: "Success!"
Actual: "Renaming: Not a directory, /home/me/test123,
/home/me/.local/share/Trash/files/test123Wiibmk"

Please let me know what you think, looking forward to getting this fixed.

Cheers,
Codruț

www.codrut.pro

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fix-moving-directories-with-the-same-name-to-trash.patch --]
[-- Type: text/x-patch; name=0001-Fix-moving-directories-with-the-same-name-to-trash.patch, Size: 1942 bytes --]

From 8aa1e9c9e55d4d3c857048b2bc5f52066d953ac7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Codru=C8=9B=20Constantin=20Gu=C8=99oi?=
 <mail+emacs@codrut.pro>
Date: Fri, 7 May 2021 19:20:45 +0100
Subject: Fix moving directories with the same name to trash

Refs: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=47135

To reproduce, save this to a `bug.el` file:

```elisp
(setq delete-by-moving-to-trash t)

(let ((test-dir "~/test123"))
  (progn
    (message "Creating directory: 1")
    (make-directory test-dir)
    (message "Deleting directory: 1")
    (delete-directory test-dir t t)

    (message "Creating directory: 2")
    (make-directory test-dir)
    (message "Deleting directory: 2")
    (delete-directory test-dir t t)

    (message "Success!")))
```

And execute with: `emacs -nw -Q -l ./bug.el`.

Expected: "Success!"
Actual: "Renaming: Not a directory, /home/me/test123,
/home/me/.local/share/Trash/files/test123Wiibmk"

Looks like the code was creating a temp file in the trash bin and then
trying to move the directory overwriting it. I assume the intent was to
only get a unique file name, and not actually create a file, reason why
I canged the function call to be `make-temp-name`.
---
 lisp/files.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/files.el b/lisp/files.el
index 93a0e07aba..da33ee815f 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -7932,7 +7932,7 @@ move-file-to-trash
                         (expand-file-name files-base trash-files-dir))
                    (setq overwrite t
                          files-base (file-name-nondirectory
-                                     (make-temp-file
+                                     (make-temp-name
                                       (expand-file-name
                                        files-base trash-files-dir)))))
 		 (setq info-fn (expand-file-name
-- 
2.31.1


             reply	other threads:[~2021-05-07 19:31 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-07 19:31 mail--- via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2021-05-08 11:40 ` bug#48280: 28.0.50; Fix moving directories with the same name to trash Lars Ingebrigtsen
2021-05-08 11:44   ` Lars Ingebrigtsen
2021-05-08 11:53   ` mail--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-05-08 12:03     ` Lars Ingebrigtsen
2021-05-19 10:29     ` mail--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-05-24 22:23       ` Lars Ingebrigtsen
2021-05-24 23:11         ` mail--- via Bug reports for GNU Emacs, the Swiss army knife of text editors

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=6ae67348-9c12-ba4c-318a-5d6b50cfd92c@codrut.pro \
    --to=bug-gnu-emacs@gnu.org \
    --cc=48280@debbugs.gnu.org \
    --cc=mail@codrut.pro \
    /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).