Commit 9cf3544e authored by Michael Albinus's avatar Michael Albinus
Browse files

* net/tramp.el (tramp-do-copy-or-rename-file-out-of-band): Fix an

error when FILENAME and NEWNAME are existing remote directories.

* net/tramp-compat.el (tramp-compat-make-temp-file): Add optional
parameter DIR-FLAG.
parent 714997de
2010-03-02 Michael Albinus <michael.albinus@gmx.de>
* net/tramp.el (tramp-do-copy-or-rename-file-out-of-band): Fix an
error when FILENAME and NEWNAME are existing remote directories.
* net/tramp-compat.el (tramp-compat-make-temp-file): Add optional
parameter DIR-FLAG.
2010-03-02 Glenn Morris <rgm@gnu.org> 2010-03-02 Glenn Morris <rgm@gnu.org>
* calendar/cal-hebrew.el (holiday-hebrew-passover): Fix date * calendar/cal-hebrew.el (holiday-hebrew-passover): Fix date
......
...@@ -215,7 +215,7 @@ this is the function `temp-directory'." ...@@ -215,7 +215,7 @@ this is the function `temp-directory'."
;; has been introduced with Emacs 22. We try it, if it fails, we fall ;; has been introduced with Emacs 22. We try it, if it fails, we fall
;; back to `make-temp-name', creating the temporary file immediately ;; back to `make-temp-name', creating the temporary file immediately
;; in order to avoid a security hole. ;; in order to avoid a security hole.
(defsubst tramp-compat-make-temp-file (filename) (defsubst tramp-compat-make-temp-file (filename &optional dir-flag)
"Create a temporary file (compat function). "Create a temporary file (compat function).
Add the extension of FILENAME, if existing." Add the extension of FILENAME, if existing."
(let* (file-name-handler-alist (let* (file-name-handler-alist
...@@ -226,21 +226,24 @@ Add the extension of FILENAME, if existing." ...@@ -226,21 +226,24 @@ Add the extension of FILENAME, if existing."
result) result)
(condition-case nil (condition-case nil
(setq result (setq result
(funcall (symbol-function 'make-temp-file) prefix nil extension)) (funcall
(symbol-function 'make-temp-file) prefix dir-flag extension))
(error (error
;; We use our own implementation, taken from files.el. ;; We use our own implementation, taken from files.el.
(while (while
(condition-case () (condition-case ()
(progn (progn
(setq result (concat (make-temp-name prefix) extension)) (setq result (concat (make-temp-name prefix) extension))
(write-region (if dir-flag
"" nil result nil 'silent nil (make-directory result)
;; 7th parameter is MUSTBENEW in Emacs, and (write-region
;; CODING-SYSTEM in XEmacs. It is not a security "" nil result nil 'silent nil
;; hole in XEmacs if we cannot use this parameter, ;; 7th parameter is MUSTBENEW in Emacs, and
;; because XEmacs uses a user-specific subdirectory ;; CODING-SYSTEM in XEmacs. It is not a security
;; with 0700 permissions. ;; hole in XEmacs if we cannot use this parameter,
(when (not (featurep 'xemacs)) 'excl)) ;; because XEmacs uses a user-specific
;; subdirectory with 0700 permissions.
(when (not (featurep 'xemacs)) 'excl)))
nil) nil)
(file-already-exists t)) (file-already-exists t))
;; The file was somehow created by someone else between ;; The file was somehow created by someone else between
......
...@@ -3798,13 +3798,12 @@ The method used must be an out-of-band method." ...@@ -3798,13 +3798,12 @@ The method used must be an out-of-band method."
;; Both are Tramp files. We shall optimize it, when the ;; Both are Tramp files. We shall optimize it, when the
;; methods for filename and newname are the same. ;; methods for filename and newname are the same.
(let ((tmpfile (let* ((dir-flag (file-directory-p filename))
(if (file-regular-p filename) (tmpfile (tramp-compat-make-temp-file localname dir-flag)))
(tramp-compat-make-temp-file localname) (if dir-flag
(make-temp-name (setq tmpfile
(expand-file-name (expand-file-name
tramp-temp-name-prefix (file-name-nondirectory newname) tmpfile)))
(tramp-compat-temporary-file-directory))))))
(unwind-protect (unwind-protect
(progn (progn
(tramp-do-copy-or-rename-file-out-of-band (tramp-do-copy-or-rename-file-out-of-band
...@@ -3813,9 +3812,10 @@ The method used must be an out-of-band method." ...@@ -3813,9 +3812,10 @@ The method used must be an out-of-band method."
'rename tmpfile newname keep-date)) 'rename tmpfile newname keep-date))
;; Save exit. ;; Save exit.
(condition-case nil (condition-case nil
(if (file-regular-p tmpfile) (if dir-flag
(delete-file tmpfile) (delete-directory
(delete-directory tmpfile 'recursive)) (expand-file-name ".." tmpfile) 'recursive)
(delete-file tmpfile))
(error)))) (error))))
;; Expand hops. Might be necessary for gateway methods. ;; Expand hops. Might be necessary for gateway methods.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment