diff options
| author | Michael Albinus | 2009-01-05 19:37:01 +0000 |
|---|---|---|
| committer | Michael Albinus | 2009-01-05 19:37:01 +0000 |
| commit | ce2cc72811df63f5a6966e910222bc9d79d4cf29 (patch) | |
| tree | b44375c1c4131d3ca94eb18018e33dc8efe3aba5 | |
| parent | 77fea89de1d7d20f967c467a80d8c731edced05c (diff) | |
| download | emacs-ce2cc72811df63f5a6966e910222bc9d79d4cf29.tar.gz emacs-ce2cc72811df63f5a6966e910222bc9d79d4cf29.zip | |
* 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): Delete temporary file in case of
error.
| -rw-r--r-- | lisp/net/tramp.el | 130 |
1 files changed, 73 insertions, 57 deletions
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index 78f82b9f3ca..1714efb80cb 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el | |||
| @@ -2263,8 +2263,9 @@ target of the symlink differ." | |||
| 2263 | (unless nomessage (tramp-message v 0 "Loading %s..." file)) | 2263 | (unless nomessage (tramp-message v 0 "Loading %s..." file)) |
| 2264 | (let ((local-copy (file-local-copy file))) | 2264 | (let ((local-copy (file-local-copy file))) |
| 2265 | ;; MUST-SUFFIX doesn't exist on XEmacs, so let it default to nil. | 2265 | ;; MUST-SUFFIX doesn't exist on XEmacs, so let it default to nil. |
| 2266 | (load local-copy noerror t t) | 2266 | (unwind-protect |
| 2267 | (delete-file local-copy)) | 2267 | (load local-copy noerror t t) |
| 2268 | (delete-file local-copy))) | ||
| 2268 | (unless nomessage (tramp-message v 0 "Loading %s...done" file)) | 2269 | (unless nomessage (tramp-message v 0 "Loading %s...done" file)) |
| 2269 | t))) | 2270 | t))) |
| 2270 | 2271 | ||
| @@ -3258,45 +3259,51 @@ the uid and gid from FILENAME." | |||
| 3258 | 3259 | ||
| 3259 | ;; We need a temporary file in between. | 3260 | ;; We need a temporary file in between. |
| 3260 | (t | 3261 | (t |
| 3261 | ;; Create the temporary file. | 3262 | (condition-case err |
| 3262 | (let ((tmpfile (tramp-compat-make-temp-file localname1))) | 3263 | ;; Create the temporary file. |
| 3263 | (cond | 3264 | (let ((tmpfile (tramp-compat-make-temp-file localname1))) |
| 3264 | (t1 | 3265 | (cond |
| 3265 | (tramp-send-command | 3266 | (t1 |
| 3266 | v (format | 3267 | (tramp-send-command |
| 3267 | "%s %s %s" cmd | 3268 | v (format |
| 3268 | (tramp-shell-quote-argument localname1) | 3269 | "%s %s %s" cmd |
| 3269 | (tramp-shell-quote-argument tmpfile))) | 3270 | (tramp-shell-quote-argument localname1) |
| 3270 | ;; We must change the ownership as remote user. | 3271 | (tramp-shell-quote-argument tmpfile))) |
| 3271 | (tramp-set-file-uid-gid | 3272 | ;; We must change the ownership as remote user. |
| 3272 | (concat prefix tmpfile) | 3273 | (tramp-set-file-uid-gid |
| 3273 | (tramp-get-local-uid 'integer) | 3274 | (concat prefix tmpfile) |
| 3274 | (tramp-get-local-gid 'integer))) | 3275 | (tramp-get-local-uid 'integer) |
| 3275 | (t2 | 3276 | (tramp-get-local-gid 'integer))) |
| 3276 | (if (eq op 'copy) | 3277 | (t2 |
| 3277 | (tramp-compat-copy-file | 3278 | (if (eq op 'copy) |
| 3278 | localname1 tmpfile ok-if-already-exists | 3279 | (tramp-compat-copy-file |
| 3279 | keep-date preserve-uid-gid) | 3280 | localname1 tmpfile ok-if-already-exists |
| 3280 | (tramp-run-real-handler | 3281 | keep-date preserve-uid-gid) |
| 3281 | 'rename-file (list localname1 tmpfile ok-if-already-exists))) | 3282 | (tramp-run-real-handler |
| 3282 | ;; We must change the ownership as local user. | 3283 | 'rename-file |
| 3283 | (tramp-set-file-uid-gid | 3284 | (list localname1 tmpfile ok-if-already-exists))) |
| 3284 | tmpfile | 3285 | ;; We must change the ownership as local user. |
| 3285 | (tramp-get-remote-uid v 'integer) | 3286 | (tramp-set-file-uid-gid |
| 3286 | (tramp-get-remote-gid v 'integer)))) | 3287 | tmpfile |
| 3287 | 3288 | (tramp-get-remote-uid v 'integer) | |
| 3288 | ;; Move the temporary file to its destination. | 3289 | (tramp-get-remote-gid v 'integer)))) |
| 3289 | (cond | 3290 | |
| 3290 | (t2 | 3291 | ;; Move the temporary file to its destination. |
| 3291 | (tramp-send-command | 3292 | (cond |
| 3292 | v (format | 3293 | (t2 |
| 3293 | "mv -f %s %s" | 3294 | (tramp-send-command |
| 3294 | (tramp-shell-quote-argument tmpfile) | 3295 | v (format |
| 3295 | (tramp-shell-quote-argument localname2)))) | 3296 | "mv -f %s %s" |
| 3296 | (t1 | 3297 | (tramp-shell-quote-argument tmpfile) |
| 3297 | (tramp-run-real-handler | 3298 | (tramp-shell-quote-argument localname2)))) |
| 3298 | 'rename-file | 3299 | (t1 |
| 3299 | (list tmpfile localname2 ok-if-already-exists)))))))))) | 3300 | (tramp-run-real-handler |
| 3301 | 'rename-file | ||
| 3302 | (list tmpfile localname2 ok-if-already-exists))))) | ||
| 3303 | |||
| 3304 | ;; Error handling. | ||
| 3305 | (error (delete-file tmpfile) | ||
| 3306 | (signal (car err) (cdr err))))))))) | ||
| 3300 | 3307 | ||
| 3301 | ;; Set the time and mode. Mask possible errors. | 3308 | ;; Set the time and mode. Mask possible errors. |
| 3302 | ;; Won't be applied for 'rename. | 3309 | ;; Won't be applied for 'rename. |
| @@ -4051,8 +4058,9 @@ Lisp error raised when PROGRAM is nil is trapped also, returning 1." | |||
| 4051 | (tramp-message | 4058 | (tramp-message |
| 4052 | v 5 "Decoding remote file %s with command %s..." | 4059 | v 5 "Decoding remote file %s with command %s..." |
| 4053 | filename loc-dec) | 4060 | filename loc-dec) |
| 4054 | (tramp-call-local-coding-command loc-dec tmpfile2 tmpfile) | 4061 | (unwind-protect |
| 4055 | (delete-file tmpfile2))) | 4062 | (tramp-call-local-coding-command loc-dec tmpfile2 tmpfile) |
| 4063 | (delete-file tmpfile2)))) | ||
| 4056 | (tramp-message v 5 "Decoding remote file %s...done" filename) | 4064 | (tramp-message v 5 "Decoding remote file %s...done" filename) |
| 4057 | ;; Set proper permissions. | 4065 | ;; Set proper permissions. |
| 4058 | (set-file-modes tmpfile (file-modes filename)) | 4066 | (set-file-modes tmpfile (file-modes filename)) |
| @@ -4134,18 +4142,19 @@ coding system might not be determined. This function repairs it." | |||
| 4134 | (tramp-message v 4 "Inserting local temp file `%s'..." local-copy) | 4142 | (tramp-message v 4 "Inserting local temp file `%s'..." local-copy) |
| 4135 | ;; We must ensure that `file-coding-system-alist' matches | 4143 | ;; We must ensure that `file-coding-system-alist' matches |
| 4136 | ;; `local-copy'. | 4144 | ;; `local-copy'. |
| 4137 | (let ((file-coding-system-alist | 4145 | (unwind-protect |
| 4138 | (tramp-find-file-name-coding-system-alist | 4146 | (let ((file-coding-system-alist |
| 4139 | filename local-copy))) | 4147 | (tramp-find-file-name-coding-system-alist |
| 4140 | (setq result | 4148 | filename local-copy))) |
| 4141 | (insert-file-contents local-copy nil beg end replace)) | 4149 | (setq result |
| 4142 | ;; Now `last-coding-system-used' has right value. Remember it. | 4150 | (insert-file-contents local-copy nil beg end replace)) |
| 4143 | (when (boundp 'last-coding-system-used) | 4151 | ;; Now `last-coding-system-used' has right value. Remember it. |
| 4144 | (setq coding-system-used | 4152 | (when (boundp 'last-coding-system-used) |
| 4145 | (symbol-value 'last-coding-system-used)))) | 4153 | (setq coding-system-used |
| 4154 | (symbol-value 'last-coding-system-used)))) | ||
| 4155 | (delete-file local-copy)) | ||
| 4146 | (tramp-message | 4156 | (tramp-message |
| 4147 | v 4 "Inserting local temp file `%s'...done" local-copy) | 4157 | v 4 "Inserting local temp file `%s'...done" local-copy) |
| 4148 | (delete-file local-copy) | ||
| 4149 | (when (boundp 'last-coding-system-used) | 4158 | (when (boundp 'last-coding-system-used) |
| 4150 | (set 'last-coding-system-used coding-system-used)))) | 4159 | (set 'last-coding-system-used coding-system-used)))) |
| 4151 | 4160 | ||
| @@ -4333,9 +4342,13 @@ Returns a file name in `tramp-auto-save-directory' for autosaving this file." | |||
| 4333 | ;; matches `tmpfile'. | 4342 | ;; matches `tmpfile'. |
| 4334 | (let ((file-coding-system-alist | 4343 | (let ((file-coding-system-alist |
| 4335 | (tramp-find-file-name-coding-system-alist filename tmpfile))) | 4344 | (tramp-find-file-name-coding-system-alist filename tmpfile))) |
| 4336 | (tramp-run-real-handler | 4345 | (condition-case err |
| 4337 | 'write-region | 4346 | (tramp-run-real-handler |
| 4338 | (list start end tmpfile append 'no-message lockname confirm)) | 4347 | 'write-region |
| 4348 | (list start end tmpfile append 'no-message lockname confirm)) | ||
| 4349 | (error (delete-file tmpfile) | ||
| 4350 | (signal (car err) (cdr err)))) | ||
| 4351 | |||
| 4339 | ;; Now, `last-coding-system-used' has the right value. Remember it. | 4352 | ;; Now, `last-coding-system-used' has the right value. Remember it. |
| 4340 | (when (boundp 'last-coding-system-used) | 4353 | (when (boundp 'last-coding-system-used) |
| 4341 | (setq coding-system-used | 4354 | (setq coding-system-used |
| @@ -4360,7 +4373,10 @@ Returns a file name in `tramp-auto-save-directory' for autosaving this file." | |||
| 4360 | (and (tramp-method-out-of-band-p v) | 4373 | (and (tramp-method-out-of-band-p v) |
| 4361 | (> (- (or end (point-max)) (or start (point-min))) | 4374 | (> (- (or end (point-max)) (or start (point-min))) |
| 4362 | tramp-copy-size-limit))) | 4375 | tramp-copy-size-limit))) |
| 4363 | (rename-file tmpfile filename t)) | 4376 | (condition-case err |
| 4377 | (rename-file tmpfile filename t) | ||
| 4378 | (error (delete-file tmpfile) | ||
| 4379 | (signal (car err) (cdr err))))) | ||
| 4364 | 4380 | ||
| 4365 | ;; Use inline file transfer. | 4381 | ;; Use inline file transfer. |
| 4366 | (rem-dec | 4382 | (rem-dec |