aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2009-06-07 16:17:03 +0000
committerMichael Albinus2009-06-07 16:17:03 +0000
commit917b89a691a5d7c8ae442a6f2e7bc1230efded00 (patch)
treec00a23edfd9ca09dd274c09141d5222335e4ab02
parent630100ea9fcbb4a44b27b5f57623c931030a9c8e (diff)
downloademacs-917b89a691a5d7c8ae442a6f2e7bc1230efded00.tar.gz
emacs-917b89a691a5d7c8ae442a6f2e7bc1230efded00.zip
* net/tramp.el (tramp-do-copy-or-rename-file-directly): Make direct
copy more robust, especially when "chown" is not applicable.
-rw-r--r--lisp/ChangeLog5
-rw-r--r--lisp/net/tramp.el49
2 files changed, 39 insertions, 15 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 4f451446920..7072bb05fed 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
12009-06-07 Michael Albinus <michael.albinus@gmx.de>
2
3 * net/tramp.el (tramp-do-copy-or-rename-file-directly): Make direct
4 copy more robust, especially when "chown" is not applicable.
5
12009-06-07 Martin Rudalics <rudalics@gmx.at> 62009-06-07 Martin Rudalics <rudalics@gmx.at>
2 7
3 * emacs-lisp/lisp-mode.el (lisp-mode-variables): Fix doc-string. 8 * emacs-lisp/lisp-mode.el (lisp-mode-variables): Fix doc-string.
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index b6bfcf70901..5b51d6cc966 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -3270,16 +3270,26 @@ the uid and gid from FILENAME."
3270 (t 3270 (t
3271 ;; Create the temporary file. 3271 ;; Create the temporary file.
3272 (let ((tmpfile (tramp-compat-make-temp-file localname1))) 3272 (let ((tmpfile (tramp-compat-make-temp-file localname1)))
3273 (condition-case err 3273 (unwind-protect
3274 (progn 3274 (progn
3275 (cond 3275 (cond
3276 (t1 3276 (t1
3277 (tramp-send-command 3277 (or
3278 v (format 3278 (zerop
3279 "%s %s %s" cmd 3279 (tramp-send-command-and-check
3280 (tramp-shell-quote-argument localname1) 3280 v (format
3281 (tramp-shell-quote-argument tmpfile))) 3281 "%s %s %s" cmd
3282 (tramp-shell-quote-argument localname1)
3283 (tramp-shell-quote-argument tmpfile))))
3284 (tramp-error-with-buffer
3285 nil v 'file-error
3286 "Copying directly failed, see buffer `%s' for details."
3287 (tramp-get-buffer v)))
3282 ;; We must change the ownership as remote user. 3288 ;; We must change the ownership as remote user.
3289 ;; Since this does not work reliable, we also
3290 ;; give read permissions.
3291 (set-file-modes
3292 (concat prefix tmpfile) (tramp-octal-to-decimal "0777"))
3283 (tramp-set-file-uid-gid 3293 (tramp-set-file-uid-gid
3284 (concat prefix tmpfile) 3294 (concat prefix tmpfile)
3285 (tramp-get-local-uid 'integer) 3295 (tramp-get-local-uid 'integer)
@@ -3293,6 +3303,9 @@ the uid and gid from FILENAME."
3293 'rename-file 3303 'rename-file
3294 (list localname1 tmpfile t))) 3304 (list localname1 tmpfile t)))
3295 ;; We must change the ownership as local user. 3305 ;; We must change the ownership as local user.
3306 ;; Since this does not work reliable, we also
3307 ;; give read permissions.
3308 (set-file-modes tmpfile (tramp-octal-to-decimal "0777"))
3296 (tramp-set-file-uid-gid 3309 (tramp-set-file-uid-gid
3297 tmpfile 3310 tmpfile
3298 (tramp-get-remote-uid v 'integer) 3311 (tramp-get-remote-uid v 'integer)
@@ -3301,20 +3314,26 @@ the uid and gid from FILENAME."
3301 ;; Move the temporary file to its destination. 3314 ;; Move the temporary file to its destination.
3302 (cond 3315 (cond
3303 (t2 3316 (t2
3304 (tramp-send-command 3317 (or
3305 v (format 3318 (zerop
3306 "mv -f %s %s" 3319 (tramp-send-command-and-check
3307 (tramp-shell-quote-argument tmpfile) 3320 v (format
3308 (tramp-shell-quote-argument localname2)))) 3321 "cp -f -p %s %s"
3322 (tramp-shell-quote-argument tmpfile)
3323 (tramp-shell-quote-argument localname2))))
3324 (tramp-error-with-buffer
3325 nil v 'file-error
3326 "Copying directly failed, see buffer `%s' for details."
3327 (tramp-get-buffer v))))
3309 (t1 3328 (t1
3310 (tramp-run-real-handler 3329 (tramp-run-real-handler
3311 'rename-file 3330 'rename-file
3312 (list tmpfile localname2 ok-if-already-exists))))) 3331 (list tmpfile localname2 ok-if-already-exists)))))
3313 3332
3314 ;; Error handling. 3333 ;; Save exit.
3315 ((error quit) 3334 (condition-case nil
3316 (delete-file tmpfile) 3335 (delete-file tmpfile)
3317 (signal (car err) (cdr err)))))))))) 3336 (error)))))))))
3318 3337
3319 ;; Set the time and mode. Mask possible errors. 3338 ;; Set the time and mode. Mask possible errors.
3320 ;; Won't be applied for 'rename. 3339 ;; Won't be applied for 'rename.