diff options
| author | Michael Albinus | 2009-01-06 07:51:09 +0000 |
|---|---|---|
| committer | Michael Albinus | 2009-01-06 07:51:09 +0000 |
| commit | 2988341a84f6e5faef7e5f5ce2c55142935d0fee (patch) | |
| tree | 2894ab6dd8e79d3dc3ab4589fb7afeee305c1b53 | |
| parent | 1bba1cfc46bc13ee9be30614086b7005d5a0c1df (diff) | |
| download | emacs-2988341a84f6e5faef7e5f5ce2c55142935d0fee.tar.gz emacs-2988341a84f6e5faef7e5f5ce2c55142935d0fee.zip | |
* 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.
| -rw-r--r-- | lisp/net/tramp.el | 119 |
1 files changed, 66 insertions, 53 deletions
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index 1714efb80cb..04781c7b2c2 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el | |||
| @@ -3302,8 +3302,9 @@ the uid and gid from FILENAME." | |||
| 3302 | (list tmpfile localname2 ok-if-already-exists))))) | 3302 | (list tmpfile localname2 ok-if-already-exists))))) |
| 3303 | 3303 | ||
| 3304 | ;; Error handling. | 3304 | ;; Error handling. |
| 3305 | (error (delete-file tmpfile) | 3305 | ((error quit) |
| 3306 | (signal (car err) (cdr err))))))))) | 3306 | (delete-file tmpfile) |
| 3307 | (signal (car err) (cdr err))))))))) | ||
| 3307 | 3308 | ||
| 3308 | ;; Set the time and mode. Mask possible errors. | 3309 | ;; Set the time and mode. Mask possible errors. |
| 3309 | ;; Won't be applied for 'rename. | 3310 | ;; Won't be applied for 'rename. |
| @@ -4011,36 +4012,39 @@ Lisp error raised when PROGRAM is nil is trapped also, returning 1." | |||
| 4011 | "Like `file-local-copy' for Tramp files." | 4012 | "Like `file-local-copy' for Tramp files." |
| 4012 | 4013 | ||
| 4013 | (with-parsed-tramp-file-name filename nil | 4014 | (with-parsed-tramp-file-name filename nil |
| 4015 | (unless (file-exists-p filename) | ||
| 4016 | (tramp-error | ||
| 4017 | v 'file-error | ||
| 4018 | "Cannot make local copy of non-existing file `%s'" filename)) | ||
| 4019 | |||
| 4014 | (let ((rem-enc (tramp-get-remote-coding v "remote-encoding")) | 4020 | (let ((rem-enc (tramp-get-remote-coding v "remote-encoding")) |
| 4015 | (loc-dec (tramp-get-local-coding v "local-decoding")) | 4021 | (loc-dec (tramp-get-local-coding v "local-decoding")) |
| 4016 | (tmpfile (tramp-compat-make-temp-file filename))) | 4022 | (tmpfile (tramp-compat-make-temp-file filename))) |
| 4017 | (unless (file-exists-p filename) | ||
| 4018 | (tramp-error | ||
| 4019 | v 'file-error | ||
| 4020 | "Cannot make local copy of non-existing file `%s'" filename)) | ||
| 4021 | 4023 | ||
| 4022 | (cond | 4024 | (condition-case err |
| 4023 | ;; `copy-file' handles direct copy and out-of-band methods. | 4025 | (cond |
| 4024 | ((or (tramp-local-host-p v) | 4026 | ;; `copy-file' handles direct copy and out-of-band methods. |
| 4025 | (and (tramp-method-out-of-band-p v) | 4027 | ((or (tramp-local-host-p v) |
| 4026 | (> (nth 7 (file-attributes filename)) tramp-copy-size-limit))) | 4028 | (and (tramp-method-out-of-band-p v) |
| 4027 | (copy-file filename tmpfile t t)) | 4029 | (> (nth 7 (file-attributes filename)) |
| 4028 | 4030 | tramp-copy-size-limit))) | |
| 4029 | ;; Use inline encoding for file transfer. | 4031 | (copy-file filename tmpfile t t)) |
| 4030 | (rem-enc | 4032 | |
| 4031 | (save-excursion | 4033 | ;; Use inline encoding for file transfer. |
| 4032 | (tramp-message v 5 "Encoding remote file %s..." filename) | 4034 | (rem-enc |
| 4033 | (tramp-barf-unless-okay | 4035 | (save-excursion |
| 4034 | v (format "%s < %s" rem-enc (tramp-shell-quote-argument localname)) | 4036 | (tramp-message v 5 "Encoding remote file %s..." filename) |
| 4035 | "Encoding remote file failed") | 4037 | (tramp-barf-unless-okay |
| 4036 | (tramp-message v 5 "Encoding remote file %s...done" filename) | 4038 | v |
| 4037 | 4039 | (format "%s < %s" rem-enc (tramp-shell-quote-argument localname)) | |
| 4038 | (tramp-message v 5 "Decoding remote file %s..." filename) | 4040 | "Encoding remote file failed") |
| 4039 | (if (and (symbolp loc-dec) (fboundp loc-dec)) | 4041 | (tramp-message v 5 "Encoding remote file %s...done" filename) |
| 4040 | ;; If local decoding is a function, we call it. We must | 4042 | |
| 4041 | ;; disable multibyte, because `uudecode-decode-region' | 4043 | (if (and (symbolp loc-dec) (fboundp loc-dec)) |
| 4042 | ;; doesn't handle it correctly. | 4044 | ;; If local decoding is a function, we call it. We |
| 4043 | (unwind-protect | 4045 | ;; must disable multibyte, because |
| 4046 | ;; `uudecode-decode-region' doesn't handle it | ||
| 4047 | ;; correctly. | ||
| 4044 | (with-temp-buffer | 4048 | (with-temp-buffer |
| 4045 | (set-buffer-multibyte nil) | 4049 | (set-buffer-multibyte nil) |
| 4046 | (insert-buffer-substring (tramp-get-buffer v)) | 4050 | (insert-buffer-substring (tramp-get-buffer v)) |
| @@ -4049,27 +4053,34 @@ Lisp error raised when PROGRAM is nil is trapped also, returning 1." | |||
| 4049 | filename loc-dec) | 4053 | filename loc-dec) |
| 4050 | (funcall loc-dec (point-min) (point-max)) | 4054 | (funcall loc-dec (point-min) (point-max)) |
| 4051 | (let ((coding-system-for-write 'binary)) | 4055 | (let ((coding-system-for-write 'binary)) |
| 4052 | (write-region (point-min) (point-max) tmpfile)))) | 4056 | (write-region (point-min) (point-max) tmpfile))) |
| 4053 | ;; If tramp-decoding-function is not defined for this | 4057 | |
| 4054 | ;; method, we invoke tramp-decoding-command instead. | 4058 | ;; If tramp-decoding-function is not defined for this |
| 4055 | (let ((tmpfile2 (tramp-compat-make-temp-file filename))) | 4059 | ;; method, we invoke tramp-decoding-command instead. |
| 4056 | (let ((coding-system-for-write 'binary)) | 4060 | (let ((tmpfile2 (tramp-compat-make-temp-file filename))) |
| 4057 | (write-region (point-min) (point-max) tmpfile2)) | 4061 | (let ((coding-system-for-write 'binary)) |
| 4058 | (tramp-message | 4062 | (write-region (point-min) (point-max) tmpfile2)) |
| 4059 | v 5 "Decoding remote file %s with command %s..." | 4063 | (tramp-message |
| 4060 | filename loc-dec) | 4064 | v 5 "Decoding remote file %s with command %s..." |
| 4061 | (unwind-protect | 4065 | filename loc-dec) |
| 4062 | (tramp-call-local-coding-command loc-dec tmpfile2 tmpfile) | 4066 | (unwind-protect |
| 4063 | (delete-file tmpfile2)))) | 4067 | (tramp-call-local-coding-command loc-dec tmpfile2 tmpfile) |
| 4064 | (tramp-message v 5 "Decoding remote file %s...done" filename) | 4068 | (delete-file tmpfile2)))) |
| 4065 | ;; Set proper permissions. | 4069 | |
| 4066 | (set-file-modes tmpfile (file-modes filename)) | 4070 | (tramp-message v 5 "Decoding remote file %s...done" filename) |
| 4067 | ;; Set local user ownership. | 4071 | ;; Set proper permissions. |
| 4068 | (tramp-set-file-uid-gid tmpfile))) | 4072 | (set-file-modes tmpfile (file-modes filename)) |
| 4069 | 4073 | ;; Set local user ownership. | |
| 4070 | ;; Oops, I don't know what to do. | 4074 | (tramp-set-file-uid-gid tmpfile))) |
| 4071 | (t (tramp-error | 4075 | |
| 4072 | v 'file-error "Wrong method specification for `%s'" method))) | 4076 | ;; Oops, I don't know what to do. |
| 4077 | (t (tramp-error | ||
| 4078 | v 'file-error "Wrong method specification for `%s'" method))) | ||
| 4079 | |||
| 4080 | ;; Error handling. | ||
| 4081 | ((error quit) | ||
| 4082 | (delete-file tmpfile) | ||
| 4083 | (signal (car err) (cdr err)))) | ||
| 4073 | 4084 | ||
| 4074 | (run-hooks 'tramp-handle-file-local-copy-hook) | 4085 | (run-hooks 'tramp-handle-file-local-copy-hook) |
| 4075 | tmpfile))) | 4086 | tmpfile))) |
| @@ -4346,8 +4357,9 @@ Returns a file name in `tramp-auto-save-directory' for autosaving this file." | |||
| 4346 | (tramp-run-real-handler | 4357 | (tramp-run-real-handler |
| 4347 | 'write-region | 4358 | 'write-region |
| 4348 | (list start end tmpfile append 'no-message lockname confirm)) | 4359 | (list start end tmpfile append 'no-message lockname confirm)) |
| 4349 | (error (delete-file tmpfile) | 4360 | ((error quit) |
| 4350 | (signal (car err) (cdr err)))) | 4361 | (delete-file tmpfile) |
| 4362 | (signal (car err) (cdr err)))) | ||
| 4351 | 4363 | ||
| 4352 | ;; Now, `last-coding-system-used' has the right value. Remember it. | 4364 | ;; Now, `last-coding-system-used' has the right value. Remember it. |
| 4353 | (when (boundp 'last-coding-system-used) | 4365 | (when (boundp 'last-coding-system-used) |
| @@ -4375,8 +4387,9 @@ Returns a file name in `tramp-auto-save-directory' for autosaving this file." | |||
| 4375 | tramp-copy-size-limit))) | 4387 | tramp-copy-size-limit))) |
| 4376 | (condition-case err | 4388 | (condition-case err |
| 4377 | (rename-file tmpfile filename t) | 4389 | (rename-file tmpfile filename t) |
| 4378 | (error (delete-file tmpfile) | 4390 | ((error quit) |
| 4379 | (signal (car err) (cdr err))))) | 4391 | (delete-file tmpfile) |
| 4392 | (signal (car err) (cdr err))))) | ||
| 4380 | 4393 | ||
| 4381 | ;; Use inline file transfer. | 4394 | ;; Use inline file transfer. |
| 4382 | (rem-dec | 4395 | (rem-dec |