From: Thierry Volpiatto <thierry.volpiatto@gmail.com>
To: emacs-devel@gnu.org
Subject: Re: dired-do-copy may create infinite directory hierarchy, again
Date: Thu, 29 Mar 2012 19:45:16 +0200 [thread overview]
Message-ID: <87pqbv5mj7.fsf@gmail.com> (raw)
In-Reply-To: 87bonf7vu8.fsf@gmail.com
[-- Attachment #1: Type: text/plain, Size: 560 bytes --]
Thierry Volpiatto <thierry.volpiatto@gmail.com> writes:
>> bug#10489: 24.0.92; dired-do-copy may create infinite directory hierarchy
>>
>> after it had been closed, saying that there are still problems.
>> Unfortunately I got no answer. Since it was an important bug: Can
>> please somebody have a look? Thanks.
>> But I only wanted a symlink... This worked in Emacs 23.
>>
> Need to be fixed.
The attached patch should fix this also, please review it and test it (quite
busy actually, not fully tested), and if no objections I will apply it.
Thanks.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: bugfix copy-directory/symlinks --]
[-- Type: text/x-diff, Size: 2658 bytes --]
# HG changeset patch
# User Thierry Volpiatto <thierry.volpiatto@gmail.com>
# Date 1333042420 -7200
# Node ID c2de4670a69cefd92095caca612f8b1e4fd0c217
# Parent 0c4996976cc3ded487b93f71a27641a48c127767
* lisp/files.el (copy-directory): Check if file is a directory but a symlink.
diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el
--- a/lisp/dired-aux.el
+++ b/lisp/dired-aux.el
@@ -1264,7 +1264,8 @@
(defun dired-copy-file-recursive (from to ok-flag &optional
preserve-time top recursive)
- (when (file-subdir-of-p to from)
+ (when (and (eq t (car (file-attributes from)))
+ (file-subdir-of-p to from))
(error "Cannot copy `%s' into its subdirectory `%s'" from to))
(let ((attrs (file-attributes from)))
(if (and recursive
@@ -1452,10 +1453,14 @@
(eq file-creator 'dired-copy-file))
(setq to destname))
;; If DESTNAME and FROM are the same directory or
- ;; If DESTNAME is a subdirectory of FROM, return error.
- (and (file-subdir-of-p destname from)
- (error "Cannot copy `%s' into its subdirectory `%s'"
- from to)))
+ ;; If DESTNAME is a subdirectory of FROM, not a symlink,
+ ;; and the method in use is copying return error.
+ (when (and (eq t ; A dir but not a symlink.
+ (car (file-attributes destname)))
+ (eq file-creator 'dired-copy-file)
+ (file-subdir-of-p destname from))
+ (error "Here:Cannot copy `%s' into its subdirectory `%s'"
+ from to)))
(condition-case err
(progn
(funcall file-creator from to dired-overwrite-confirmed)
diff --git a/lisp/files.el b/lisp/files.el
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -5102,10 +5102,10 @@
;; We do not want to copy "." and "..".
(directory-files directory 'full
directory-files-no-dot-files-regexp))
- (if (file-directory-p file)
- (copy-directory file newname keep-time parents)
- (let ((target (expand-file-name (file-name-nondirectory file) newname))
- (attrs (file-attributes file)))
+ (let ((target (expand-file-name (file-name-nondirectory file) newname))
+ (attrs (file-attributes file)))
+ (if (eq t (car attrs)) ; A directory but not a symlink.
+ (copy-directory file newname keep-time parents)
(if (stringp (car attrs)) ; Symbolic link
(make-symbolic-link (car attrs) target t)
(copy-file file target t keep-time)))))
[-- Attachment #3: Type: text/plain, Size: 84 bytes --]
--
Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997
prev parent reply other threads:[~2012-03-29 17:45 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-29 2:58 dired-do-copy may create infinite directory hierarchy, again Michael Heerdegen
2012-03-29 6:41 ` Thierry Volpiatto
2012-03-29 17:45 ` Thierry Volpiatto [this message]
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87pqbv5mj7.fsf@gmail.com \
--to=thierry.volpiatto@gmail.com \
--cc=emacs-devel@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 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.