+2009-01-05 Michael Albinus <michael.albinus@gmx.de>
+
+ * net/tramp.el (tramp-handle-load)
+ (tramp-do-copy-or-rename-file-directly)
+ (tramp-handle-file-local-copy, tramp-handle-insert-file-contents)
+ (tramp-handle-write-region)
+ * 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.
+
2009-01-05 Agustín Martín <agustin.martin@hispalinux.es>
* textmodes/ispell.el (ispell-check-version): Use (with-temp-buffer)
(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)
(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)))
(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