changeset 107170:1f564d6c5e1d

* net/tramp.el (tramp-do-copy-or-rename-file-out-of-band): Fix errors in copying directories. (tramp-handle-add-name-to-file, tramp-handle-copy-directory) (tramp-do-copy-or-rename-file, tramp-handle-delete-directory) (tramp-handle-delete-file) (tramp-handle-dired-recursive-delete-directory) (tramp-handle-write-region): Flush also the cache for the upper directory.
author Michael Albinus <michael.albinus@gmx.de>
date Tue, 16 Feb 2010 17:03:29 +0100
parents 566a19f1adb0
children 0d1117b6ae66 43af18bee02b 742c52095274
files lisp/ChangeLog lisp/net/tramp.el
diffstat 2 files changed, 44 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Tue Feb 16 09:46:15 2010 -0500
+++ b/lisp/ChangeLog	Tue Feb 16 17:03:29 2010 +0100
@@ -1,3 +1,14 @@
+2010-02-16  Michael Albinus  <michael.albinus@gmx.de>
+
+	* net/tramp.el (tramp-do-copy-or-rename-file-out-of-band): Fix
+	errors in copying directories.
+	(tramp-handle-add-name-to-file, tramp-handle-copy-directory)
+	(tramp-do-copy-or-rename-file, tramp-handle-delete-directory)
+	(tramp-handle-delete-file)
+	(tramp-handle-dired-recursive-delete-directory)
+	(tramp-handle-write-region): Flush also the cache for the upper
+	directory.
+
 2010-02-16  Chong Yidong  <cyd@stupidchicken.com>
 
 	* simple.el (save-interprogram-paste-before-kill): Doc fix.
--- a/lisp/net/tramp.el	Tue Feb 16 09:46:15 2010 -0500
+++ b/lisp/net/tramp.el	Tue Feb 16 17:03:29 2010 +0100
@@ -3420,6 +3420,7 @@
 	  (tramp-error
 	   v2 'file-error
 	   "add-name-to-file: file %s already exists" newname))
+	(tramp-flush-file-property v2 (file-name-directory v2-localname))
 	(tramp-flush-file-property v2 v2-localname)
 	(tramp-barf-unless-okay
 	 v1
@@ -3478,7 +3479,13 @@
 	     'copy dirname newname keep-date))
 	;; We must do it file-wise.
 	(tramp-run-real-handler
-	 'copy-directory (list dirname newname keep-date parents))))))
+	 'copy-directory (list dirname newname keep-date parents)))
+
+      ;; When newname did exist, we have wrong cached values.
+      (when t2
+	(with-parsed-tramp-file-name newname nil
+	  (tramp-flush-file-property v (file-name-directory localname))
+	  (tramp-flush-file-property v localname))))))
 
 (defun tramp-handle-rename-file
   (filename newname &optional ok-if-already-exists)
@@ -3583,11 +3590,13 @@
       ;; In case of `rename', we must flush the cache of the source file.
       (when (and t1 (eq op 'rename))
 	(with-parsed-tramp-file-name filename nil
+	  (tramp-flush-file-property v (file-name-directory localname))
 	  (tramp-flush-file-property v localname)))
 
       ;; When newname did exist, we have wrong cached values.
       (when t2
 	(with-parsed-tramp-file-name newname nil
+	  (tramp-flush-file-property v (file-name-directory localname))
 	  (tramp-flush-file-property v localname)))
 
       (with-parsed-tramp-file-name (if t1 filename newname) nil
@@ -3789,7 +3798,13 @@
 
 	  ;; Both are Tramp files.  We shall optimize it, when the
 	  ;; methods for filename and newname are the same.
-	  (let ((tmpfile (tramp-compat-make-temp-file localname)))
+	  (let ((tmpfile
+		 (if (file-regular-p filename)
+		     (tramp-compat-make-temp-file localname)
+		   (make-temp-name
+		    (expand-file-name
+		     tramp-temp-name-prefix
+		     (tramp-compat-temporary-file-directory))))))
 	    (unwind-protect
 		(progn
 		  (tramp-do-copy-or-rename-file-out-of-band
@@ -3798,7 +3813,9 @@
 		   'rename tmpfile newname keep-date))
 	      ;; Save exit.
 	      (condition-case nil
-		  (delete-file tmpfile)
+		  (if (file-regular-p tmpfile)
+		      (delete-file tmpfile)
+		    (delete-directory tmpfile 'recursive))
 		(error))))
 
 	;; Expand hops.  Might be necessary for gateway methods.
@@ -3913,7 +3930,9 @@
 
       ;; If the operation was `rename', delete the original file.
       (unless (eq op 'copy)
-	(delete-file filename)))))
+	(if (file-regular-p filename)
+	    (delete-file filename)
+	  (delete-directory filename 'recursive))))))
 
 (defun tramp-handle-make-directory (dir &optional parents)
   "Like `make-directory' for Tramp files."
@@ -3932,6 +3951,7 @@
   "Like `delete-directory' for Tramp files."
   (setq directory (expand-file-name directory))
   (with-parsed-tramp-file-name directory nil
+    (tramp-flush-file-property v (file-name-directory localname))
     (tramp-flush-directory-property v localname)
     (unless (zerop (tramp-send-command-and-check
 		    v
@@ -3945,6 +3965,7 @@
   "Like `delete-file' for Tramp files."
   (setq filename (expand-file-name filename))
   (with-parsed-tramp-file-name filename nil
+    (tramp-flush-file-property v (file-name-directory localname))
     (tramp-flush-file-property v localname)
     (unless (zerop (tramp-send-command-and-check
 		    v
@@ -3974,6 +3995,7 @@
     ;; This might take a while, allow it plenty of time.
     (tramp-wait-for-output (tramp-get-connection-process v) 120)
     ;; Make sure that it worked...
+    (tramp-flush-file-property v (file-name-directory localname))
     (tramp-flush-directory-property v localname)
     (and (file-exists-p filename)
 	 (tramp-error
@@ -4953,11 +4975,9 @@
 		  (or (file-directory-p localname)
 		      (file-writable-p localname)))))
 	  ;; Short track: if we are on the local host, we can run directly.
-	  (progn
-	    (tramp-run-real-handler
-	     'write-region
-	     (list start end localname append 'no-message lockname confirm))
-	    (tramp-flush-file-property v localname))
+	  (tramp-run-real-handler
+	   'write-region
+	   (list start end localname append 'no-message lockname confirm))
 
 	(let ((rem-dec (tramp-get-remote-coding v "remote-decoding"))
 	      (loc-enc (tramp-get-local-coding v "local-encoding"))
@@ -5121,8 +5141,7 @@
 			      " decode using `%s' failed")
 		      filename rem-dec)))
 		  (tramp-message
-		   v 5 "Decoding region into remote file %s...done" filename)
-		  (tramp-flush-file-property v localname))
+		   v 5 "Decoding region into remote file %s...done" filename))
 
 	      ;; Save exit.
 	      (delete-file tmpfile)))
@@ -5139,6 +5158,9 @@
 	  (when coding-system-used
 	    (set 'last-coding-system-used coding-system-used))))
 
+      (tramp-flush-file-property v (file-name-directory localname))
+      (tramp-flush-file-property v localname)
+
       ;; We must protect `last-coding-system-used', now we have set it
       ;; to its correct value.
       (let (last-coding-system-used (need-chown t))