unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Ruslan Bekenev <furyinbox@gmail.com>
To: bug#69117 <69117@debbugs.gnu.org>
Subject: bug#69117: 30.0.50; Cannot trash directory, if such exists in trash can
Date: Wed, 10 Apr 2024 16:55:52 +1000	[thread overview]
Message-ID: <BF2CA724-E920-4335-A9A9-D10CD7BC38CF@gmail.com> (raw)
In-Reply-To: <875xyyawwu.fsf@lco.mail-host-address-is-not-set>

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

> I cannot trash this directory


I tried to reproduce it and it seems working fine on my end. The file/dir is renamed and then stored in the trash can. In your case it should just rename the kaidan directory to kaidan~1~

Could you please share your ~system-move-file-to-trash~ variable value? 

I came up with the test for this use-case.
It seems passing. I hope someone can review the test case and see if there is better way to replicate the issue. 

P.S.
I initially sent this email to the wrong location. My apologies if it brought a little mess.

Ruslan


[-- Attachment #2: 0001-Test-dired-delete-functionality.patch --]
[-- Type: application/octet-stream, Size: 3300 bytes --]

From b202131097e2774a8e96f0d0e72c07c693977008 Mon Sep 17 00:00:00 2001
From: Ruslan Bekenev <furyinbox@gmail.com>
Date: Wed, 10 Apr 2024 12:58:07 +1000
Subject: [PATCH] Test dired delete functionality

Add test for https://debbugs.gnu.org/69117
The issue described in the bug is that a file cannot be trashed
if a file with the same name already exists in the trash bin.
The test checks this functionality and ensures that the dired delete
functionality works even in case trash bin already has the file with
the same name.
---
 test/lisp/dired-tests.el | 46 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)

diff --git a/test/lisp/dired-tests.el b/test/lisp/dired-tests.el
index 651b77500a1..d6773ac8a56 100644
--- a/test/lisp/dired-tests.el
+++ b/test/lisp/dired-tests.el
@@ -609,5 +609,51 @@ dired-test-directory-files-and-attributes
       (let ((default-directory test-dir-other))
         (files-tests--insert-directory-shows-given-free test-dir)))))
 
+(ert-deftest dired-test-bug69117 ()
+  "Test for https://debbugs.gnu.org/69117."
+  (let* ((delete-by-moving-to-trash t)
+         (dired-recursive-deletes 'always)
+         (dired-deletion-confirmer (lambda (_) t))
+         (testdir (expand-file-name "bug69117" default-directory))
+         (trash-directory (expand-file-name "trashdir" default-directory))
+         (dir-to-delete "dir-to-delete"))
+    (fmakunbound 'system-move-file-to-trash) ;; make sure file aren't moved to system trash
+    (unwind-protect
+        (progn
+          (mapc (lambda (d)
+                    (when (file-directory-p d)
+                      (delete-directory d t)))
+                  (list trash-directory testdir))
+          (make-directory trash-directory)
+          (make-directory testdir)
+          (when (file-directory-p trash-directory)
+            (progn
+              (when (file-directory-p dir-to-delete)
+                (delete-directory dir-to-delete))
+              ;; create dir-to-delete and delete it
+              (make-directory (expand-file-name dir-to-delete testdir))
+              (dired testdir)
+              (dired-toggle-marks)
+              (should (= 2 (length (directory-files trash-directory)))) ;; . and .. folders are there
+              (should (= 1 (length (dired-get-marked-files))))
+              (dired-do-delete nil)
+              (dired-toggle-marks)
+              (should (= 0 (length (dired-get-marked-files))))
+              (should (= 3 (length (directory-files trash-directory))))
+
+              ;; create dir-to-delete and delete it again
+              (make-directory (expand-file-name dir-to-delete testdir))
+              (revert-buffer)
+              (dired-toggle-marks)
+              (should (= 1 (length (dired-get-marked-files))))
+              (dired-do-delete nil)
+              (dired-toggle-marks)
+              (should (= 0 (length (dired-get-marked-files))))
+              (should (= 4 (length (directory-files trash-directory)))))))
+      (mapc (lambda (d)
+              (when (file-directory-p d)
+                (delete-directory d t)))
+            (list trash-directory testdir)))))
+
 (provide 'dired-tests)
 ;;; dired-tests.el ends here
-- 
2.44.0


  reply	other threads:[~2024-04-10  6:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-09  8:01 bug#69117: 30.0.50; Cannot trash directory, if such exists in trash can Jean Louis
2024-04-10  6:55 ` Ruslan Bekenev [this message]
2024-04-14 12:07 ` Jean Louis
2024-04-14 13:16   ` Eli Zaretskii

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=BF2CA724-E920-4335-A9A9-D10CD7BC38CF@gmail.com \
    --to=furyinbox@gmail.com \
    --cc=69117@debbugs.gnu.org \
    /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).