changeset 100923:7bf074994867

* net/tramp-smb.el (tramp-smb-handle-copy-file) (tramp-smb-handle-rename-file, tramp-smb-handle-write-region): Delete temporary file in case of error.
author Michael Albinus <michael.albinus@gmx.de>
date Mon, 05 Jan 2009 19:40:00 +0000
parents 2b84620022aa
children 28894e7d9ebc
files lisp/net/tramp-smb.el
diffstat 1 files changed, 16 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/net/tramp-smb.el	Mon Jan 05 19:37:01 2009 +0000
+++ b/lisp/net/tramp-smb.el	Mon Jan 05 19:40:00 2009 +0000
@@ -216,7 +216,10 @@
 
     (if tmpfile
 	;; Remote filename.
-	(rename-file tmpfile newname ok-if-already-exists)
+	(condition-case err
+	    (rename-file tmpfile newname ok-if-already-exists)
+	  (error (delete-file tmpfile)
+		 (signal (car err) (cdr err))))
 
       ;; Remote newname.
       (when (file-directory-p newname)
@@ -548,10 +551,13 @@
   (let ((tmpfile (file-local-copy filename)))
 
     (if tmpfile
-	;; remote filename
-	(rename-file tmpfile newname ok-if-already-exists)
+	;; Remote filename.
+	(condition-case err
+	    (rename-file tmpfile newname ok-if-already-exists)
+	  (error (delete-file tmpfile)
+		 (signal (car err) (cdr err))))
 
-      ;; remote newname
+      ;; Remote newname.
       (when (file-directory-p newname)
 	(setq newname (expand-file-name
 		      (file-name-nondirectory filename) newname)))
@@ -618,12 +624,13 @@
 	 (list start end tmpfile append 'no-message lockname)))
 
       (tramp-message v 5 "Writing tmp file %s to file %s..." tmpfile filename)
-      (if (tramp-smb-send-command v (format "put %s \"%s\"" tmpfile file))
-	  (tramp-message
-	   v 5 "Writing tmp file %s to file %s...done" tmpfile filename)
-	(tramp-error v 'file-error "Cannot write `%s'" filename))
+      (unwind-protect
+	  (if (tramp-smb-send-command v (format "put %s \"%s\"" tmpfile file))
+	      (tramp-message
+	       v 5 "Writing tmp file %s to file %s...done" tmpfile filename)
+	    (tramp-error v 'file-error "Cannot write `%s'" filename))
+	(delete-file tmpfile))
 
-      (delete-file tmpfile)
       (unless (equal curbuf (current-buffer))
 	(tramp-error
 	 v 'file-error