]> git.eshelyaron.com Git - emacs.git/commitdiff
* net/tramp.el (tramp-do-copy-or-rename-file-directly): Make direct
authorMichael Albinus <michael.albinus@gmx.de>
Sun, 7 Jun 2009 16:17:03 +0000 (16:17 +0000)
committerMichael Albinus <michael.albinus@gmx.de>
Sun, 7 Jun 2009 16:17:03 +0000 (16:17 +0000)
copy more robust, especially when "chown" is not applicable.

lisp/ChangeLog
lisp/net/tramp.el

index 4f451446920ec59a8794898a88e0a22bb74e300b..7072bb05fed21471f8e4c2348ce06c0f072dd767 100644 (file)
@@ -1,3 +1,8 @@
+2009-06-07  Michael Albinus  <michael.albinus@gmx.de>
+
+       * net/tramp.el (tramp-do-copy-or-rename-file-directly): Make direct
+       copy more robust, especially when "chown" is not applicable.
+
 2009-06-07  Martin Rudalics  <rudalics@gmx.at>
 
        * emacs-lisp/lisp-mode.el (lisp-mode-variables): Fix doc-string.
index b6bfcf709011d43193e9da6e775e2f9c9bc25c62..5b51d6cc966318815f9fffc027626148ecf1c740 100644 (file)
@@ -3270,16 +3270,26 @@ the uid and gid from FILENAME."
           (t
            ;; Create the temporary file.
            (let ((tmpfile (tramp-compat-make-temp-file localname1)))
-             (condition-case err
+             (unwind-protect
                  (progn
                    (cond
                     (t1
-                     (tramp-send-command
-                      v (format
-                         "%s %s %s" cmd
-                         (tramp-shell-quote-argument localname1)
-                         (tramp-shell-quote-argument tmpfile)))
+                     (or
+                      (zerop
+                       (tramp-send-command-and-check
+                        v (format
+                           "%s %s %s" cmd
+                           (tramp-shell-quote-argument localname1)
+                           (tramp-shell-quote-argument tmpfile))))
+                      (tramp-error-with-buffer
+                       nil v 'file-error
+                       "Copying directly failed, see buffer `%s' for details."
+                       (tramp-get-buffer v)))
                      ;; We must change the ownership as remote user.
+                     ;; Since this does not work reliable, we also
+                     ;; give read permissions.
+                     (set-file-modes
+                      (concat prefix tmpfile) (tramp-octal-to-decimal "0777"))
                      (tramp-set-file-uid-gid
                       (concat prefix tmpfile)
                       (tramp-get-local-uid 'integer)
@@ -3293,6 +3303,9 @@ the uid and gid from FILENAME."
                         'rename-file
                         (list localname1 tmpfile t)))
                      ;; We must change the ownership as local user.
+                     ;; Since this does not work reliable, we also
+                     ;; give read permissions.
+                     (set-file-modes tmpfile (tramp-octal-to-decimal "0777"))
                      (tramp-set-file-uid-gid
                       tmpfile
                       (tramp-get-remote-uid v 'integer)
@@ -3301,20 +3314,26 @@ the uid and gid from FILENAME."
                    ;; Move the temporary file to its destination.
                    (cond
                     (t2
-                     (tramp-send-command
-                      v (format
-                         "mv -f %s %s"
-                         (tramp-shell-quote-argument tmpfile)
-                         (tramp-shell-quote-argument localname2))))
+                     (or
+                      (zerop
+                       (tramp-send-command-and-check
+                        v (format
+                           "cp -f -p %s %s"
+                           (tramp-shell-quote-argument tmpfile)
+                           (tramp-shell-quote-argument localname2))))
+                      (tramp-error-with-buffer
+                       nil v 'file-error
+                       "Copying directly failed, see buffer `%s' for details."
+                       (tramp-get-buffer v))))
                     (t1
                      (tramp-run-real-handler
                       'rename-file
                       (list tmpfile localname2 ok-if-already-exists)))))
 
-               ;; Error handling.
-               ((error quit)
-                (delete-file tmpfile)
-                (signal (car err) (cdr err))))))))))
+               ;; Save exit.
+               (condition-case nil
+                   (delete-file tmpfile)
+                 (error)))))))))
 
       ;; Set the time and mode. Mask possible errors.
       ;; Won't be applied for 'rename.