all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#48280: 28.0.50; Fix moving directories with the same name to trash
@ 2021-05-07 19:31 mail--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2021-05-08 11:40 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 8+ messages in thread
From: mail--- via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2021-05-07 19:31 UTC (permalink / raw)
  To: 48280

[-- 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


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-05-24 23:11 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-05-07 19:31 bug#48280: 28.0.50; Fix moving directories with the same name to trash mail--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-05-08 11:40 ` 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

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.