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

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

bug#4739: 23.1.50; recursive delete fails


From: Sven Joachim
Subject: bug#4739: 23.1.50; recursive delete fails
Date: Fri, 23 Oct 2009 10:12:32 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux)

tags 4739 patch

On 2009-10-16 22:02 +0200, Sven Joachim wrote:

> In the following situation Emacs signals an error:
>
> $ mkdir -p /tmp/test
> $ ln -s /tmp /tmp/test
> $ emacs -Q /tmp
>
> Now move point to the 'test' directory, type 'D' and confirm that you
> want to delete the directory recursively.  An error message appears in
> the echo area:
> (file-error Removing directory Not a directory /tmp/test/tmp)

Here is a patch that should fix this issue by testing whether the 
/tmp/test/tmp subdirectory is actually a symlink.  It uses the same
trick as the dired-delete-file function to test for that condition:

--8<---------------cut here---------------start------------->8---
diff --git a/lisp/files.el b/lisp/files.el
index ce9791f..6c43131 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -4660,7 +4660,10 @@ If RECURSIVE is non-nil, all files in DIRECTORY are 
deleted as well."
       (if (and recursive (not (file-symlink-p directory)))
          (mapc
           (lambda (file)
-            (if (file-directory-p file)
+            ;; This test is equivalent to
+            ;; (and (file-directory-p file) (not (file-symlink-p file)))
+            ;; but more efficient
+            (if (eq t (car (file-attributes file)))
                 (delete-directory file recursive)
               (delete-file file)))
           ;; We do not want to delete "." and "..".
--8<---------------cut here---------------end--------------->8---

Suggested ChangeLog entry:

2009-10-23  Sven Joachim  <svenjoac@gmx.de>

        * files.el (delete-directory): Don't fail recursive deletions if
        the directory contains a symlink to another directory (Bug #4739).






reply via email to

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