Mercurial > emacs
changeset 100930:7d332b05e8ac
* net/tramp.el (tramp-do-copy-or-rename-file-directly)
(tramp-handle-file-local-copy, tramp-handle-write-region)
Delete temporary file in case of quit.
author | Michael Albinus <michael.albinus@gmx.de> |
---|---|
date | Tue, 06 Jan 2009 07:51:09 +0000 |
parents | 2677429036c3 |
children | 3b92ee10ce02 |
files | lisp/net/tramp.el |
diffstat | 1 files changed, 67 insertions(+), 54 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/net/tramp.el Tue Jan 06 04:17:04 2009 +0000 +++ b/lisp/net/tramp.el Tue Jan 06 07:51:09 2009 +0000 @@ -3302,8 +3302,9 @@ (list tmpfile localname2 ok-if-already-exists))))) ;; Error handling. - (error (delete-file tmpfile) - (signal (car err) (cdr err))))))))) + ((error quit) + (delete-file tmpfile) + (signal (car err) (cdr err))))))))) ;; Set the time and mode. Mask possible errors. ;; Won't be applied for 'rename. @@ -4011,36 +4012,39 @@ "Like `file-local-copy' for Tramp files." (with-parsed-tramp-file-name filename nil + (unless (file-exists-p filename) + (tramp-error + v 'file-error + "Cannot make local copy of non-existing file `%s'" filename)) + (let ((rem-enc (tramp-get-remote-coding v "remote-encoding")) (loc-dec (tramp-get-local-coding v "local-decoding")) (tmpfile (tramp-compat-make-temp-file filename))) - (unless (file-exists-p filename) - (tramp-error - v 'file-error - "Cannot make local copy of non-existing file `%s'" filename)) - - (cond - ;; `copy-file' handles direct copy and out-of-band methods. - ((or (tramp-local-host-p v) - (and (tramp-method-out-of-band-p v) - (> (nth 7 (file-attributes filename)) tramp-copy-size-limit))) - (copy-file filename tmpfile t t)) - - ;; Use inline encoding for file transfer. - (rem-enc - (save-excursion - (tramp-message v 5 "Encoding remote file %s..." filename) - (tramp-barf-unless-okay - v (format "%s < %s" rem-enc (tramp-shell-quote-argument localname)) - "Encoding remote file failed") - (tramp-message v 5 "Encoding remote file %s...done" filename) - - (tramp-message v 5 "Decoding remote file %s..." filename) - (if (and (symbolp loc-dec) (fboundp loc-dec)) - ;; If local decoding is a function, we call it. We must - ;; disable multibyte, because `uudecode-decode-region' - ;; doesn't handle it correctly. - (unwind-protect + + (condition-case err + (cond + ;; `copy-file' handles direct copy and out-of-band methods. + ((or (tramp-local-host-p v) + (and (tramp-method-out-of-band-p v) + (> (nth 7 (file-attributes filename)) + tramp-copy-size-limit))) + (copy-file filename tmpfile t t)) + + ;; Use inline encoding for file transfer. + (rem-enc + (save-excursion + (tramp-message v 5 "Encoding remote file %s..." filename) + (tramp-barf-unless-okay + v + (format "%s < %s" rem-enc (tramp-shell-quote-argument localname)) + "Encoding remote file failed") + (tramp-message v 5 "Encoding remote file %s...done" filename) + + (if (and (symbolp loc-dec) (fboundp loc-dec)) + ;; If local decoding is a function, we call it. We + ;; must disable multibyte, because + ;; `uudecode-decode-region' doesn't handle it + ;; correctly. (with-temp-buffer (set-buffer-multibyte nil) (insert-buffer-substring (tramp-get-buffer v)) @@ -4049,27 +4053,34 @@ filename loc-dec) (funcall loc-dec (point-min) (point-max)) (let ((coding-system-for-write 'binary)) - (write-region (point-min) (point-max) tmpfile)))) - ;; If tramp-decoding-function is not defined for this - ;; method, we invoke tramp-decoding-command instead. - (let ((tmpfile2 (tramp-compat-make-temp-file filename))) - (let ((coding-system-for-write 'binary)) - (write-region (point-min) (point-max) tmpfile2)) - (tramp-message - v 5 "Decoding remote file %s with command %s..." - filename loc-dec) - (unwind-protect - (tramp-call-local-coding-command loc-dec tmpfile2 tmpfile) - (delete-file tmpfile2)))) - (tramp-message v 5 "Decoding remote file %s...done" filename) - ;; Set proper permissions. - (set-file-modes tmpfile (file-modes filename)) - ;; Set local user ownership. - (tramp-set-file-uid-gid tmpfile))) - - ;; Oops, I don't know what to do. - (t (tramp-error - v 'file-error "Wrong method specification for `%s'" method))) + (write-region (point-min) (point-max) tmpfile))) + + ;; If tramp-decoding-function is not defined for this + ;; method, we invoke tramp-decoding-command instead. + (let ((tmpfile2 (tramp-compat-make-temp-file filename))) + (let ((coding-system-for-write 'binary)) + (write-region (point-min) (point-max) tmpfile2)) + (tramp-message + v 5 "Decoding remote file %s with command %s..." + filename loc-dec) + (unwind-protect + (tramp-call-local-coding-command loc-dec tmpfile2 tmpfile) + (delete-file tmpfile2)))) + + (tramp-message v 5 "Decoding remote file %s...done" filename) + ;; Set proper permissions. + (set-file-modes tmpfile (file-modes filename)) + ;; Set local user ownership. + (tramp-set-file-uid-gid tmpfile))) + + ;; Oops, I don't know what to do. + (t (tramp-error + v 'file-error "Wrong method specification for `%s'" method))) + + ;; Error handling. + ((error quit) + (delete-file tmpfile) + (signal (car err) (cdr err)))) (run-hooks 'tramp-handle-file-local-copy-hook) tmpfile))) @@ -4346,8 +4357,9 @@ (tramp-run-real-handler 'write-region (list start end tmpfile append 'no-message lockname confirm)) - (error (delete-file tmpfile) - (signal (car err) (cdr err)))) + ((error quit) + (delete-file tmpfile) + (signal (car err) (cdr err)))) ;; Now, `last-coding-system-used' has the right value. Remember it. (when (boundp 'last-coding-system-used) @@ -4375,8 +4387,9 @@ tramp-copy-size-limit))) (condition-case err (rename-file tmpfile filename t) - (error (delete-file tmpfile) - (signal (car err) (cdr err))))) + ((error quit) + (delete-file tmpfile) + (signal (car err) (cdr err))))) ;; Use inline file transfer. (rem-dec