]> git.eshelyaron.com Git - emacs.git/commitdiff
Improve robustness for out-of-band copy in Tramp
authorMichael Albinus <michael.albinus@gmx.de>
Tue, 31 May 2016 18:00:21 +0000 (20:00 +0200)
committerMichael Albinus <michael.albinus@gmx.de>
Tue, 31 May 2016 18:00:21 +0000 (20:00 +0200)
* lisp/net/tramp-adb.el (tramp-adb-execute-adb-command)
* lisp/net/tramp-cmds.el (tramp-append-tramp-buffers)
* lisp/net/tramp-gvfs.el (tramp-gvfs-do-copy-or-rename-file):
Cosmetic changes.

* lisp/net/tramp-sh.el (tramp-do-copy-or-rename-file-out-of-band):
Use local `default-directory'.  Simplify command to send.
Don't check return code, this was already done in
`tramp-process-actions'.
(tramp-get-inline-coding): Don't set `default-directory'.

* lisp/net/tramp.el (tramp-action-out-of-band):
Throw `out-of-band-failed'.
(tramp-process-actions): Handle `out-of-band-failed'.
(tramp-call-process, tramp-call-process-region):
Use local `default-directory'.

lisp/net/tramp-adb.el
lisp/net/tramp-cmds.el
lisp/net/tramp-gvfs.el
lisp/net/tramp-sh.el
lisp/net/tramp.el

index 1281dbbd72db5f32887e94adf148e29cae13dc58..f77e44e79cea32355051ab9e9f1004f0e59f04d6 100644 (file)
@@ -1045,7 +1045,7 @@ E.g. a host name \"192.168.1.1#5555\" returns \"192.168.1.1:5555\"
   "Returns nil on success error-output on failure."
   (when (and (> (length (tramp-file-name-host vec)) 0)
             ;; The -s switch is only available for ADB device commands.
-            (not (member (car args) (list "connect" "disconnect"))))
+            (not (member (car args) '("connect" "disconnect"))))
     (setq args (append (list "-s" (tramp-adb-get-device vec)) args)))
   (with-temp-buffer
     (prog1
index 856011fc0ee9844af639b2548d144bc87410e853..45f30042ad893b56aab1e7602c56bb68619c9f59 100644 (file)
@@ -345,7 +345,7 @@ names.  Passwords will never be included there.")
 Please note that you have set `tramp-verbose' to a value of at
 least 6.  Therefore, the contents of files might be included in
 the debug buffer(s).")
-           (add-text-properties start (point) (list 'face 'italic))))
+           (add-text-properties start (point) '(face italic))))
 
        (set-buffer-modified-p nil)
        (setq buffer-read-only t)
index ac390e5d5a6990049e73c3fb455c99313f6a3369..0e874d6c5865a1a58dc5ae14873cc6476242638d 100644 (file)
@@ -680,7 +680,7 @@ file names."
                 'tramp-gvfs-send-command v gvfs-operation
                 (append
                  (and (eq op 'copy) (or keep-date preserve-uid-gid)
-                      (list "--preserve"))
+                      '("--preserve"))
                  (list
                   (tramp-gvfs-url-file-name filename)
                   (tramp-gvfs-url-file-name newname))))
index e9f78b7d1ceceb447e0d6dcf13dc02c1fb5d7520..19f687c3433a17efa291231366ea2f13fd66174a 100644 (file)
@@ -2517,19 +2517,18 @@ The method used must be an out-of-band method."
 
                ;; Use an asynchronous process.  By this, password can
                ;; be handled.  We don't set a timeout, because the
-               ;; copying of large files can last longer than 60
-               ;; secs.
-               (let ((p (apply 'start-process-shell-command
-                               (tramp-get-connection-name v)
-                               (tramp-get-connection-buffer v)
-                               copy-program
-                               (append
-                                copy-args
-                                (list "&&" "echo" "tramp_exit_status" "0"
-                                      "||" "echo" "tramp_exit_status" "1")))))
-                 (tramp-message
-                  orig-vec 6 "%s"
-                  (mapconcat 'identity (process-command p) " "))
+               ;; copying of large files can last longer than 60 secs.
+               (let* ((command
+                       (mapconcat
+                        'identity (append (list copy-program) copy-args)
+                        " "))
+                      (p (let ((default-directory
+                                 (tramp-compat-temporary-file-directory)))
+                           (start-process-shell-command
+                            (tramp-get-connection-name v)
+                            (tramp-get-connection-buffer v)
+                            command))))
+                 (tramp-message orig-vec 6 "%s" command)
                  (tramp-set-connection-property p "vector" orig-vec)
                  (set-process-query-on-exit-flag p nil)
 
@@ -2537,23 +2536,7 @@ The method used must be an out-of-band method."
                  ;; sending the password.
                  (let ((tramp-local-end-of-line tramp-rsh-end-of-line))
                    (tramp-process-actions
-                    p v nil tramp-actions-copy-out-of-band))
-
-                 ;; Check the return code.
-                 (goto-char (point-max))
-                 (unless
-                     (re-search-backward "tramp_exit_status [0-9]+" nil t)
-                   (tramp-error
-                    orig-vec 'file-error
-                    "Couldn't find exit status of `%s'"
-                    (mapconcat 'identity (process-command p) " ")))
-                 (skip-chars-forward "^ ")
-                 (unless (zerop (read (current-buffer)))
-                   (forward-line -1)
-                   (tramp-error
-                    orig-vec 'file-error
-                    "Error copying: `%s'"
-                    (buffer-substring (point-min) (point-at-eol))))))
+                    p v nil tramp-actions-copy-out-of-band))))
 
            ;; Reset the transfer process properties.
            (tramp-set-connection-property v "process-name" nil)
@@ -5597,18 +5580,14 @@ function cell is returned to be applied on a buffer."
              `(lambda (beg end)
                 (,coding beg end)
                 (let ((coding-system-for-write 'binary)
-                      (coding-system-for-read 'binary)
-                      (default-directory
-                        (tramp-compat-temporary-file-directory)))
+                      (coding-system-for-read 'binary))
                   (apply
                    'tramp-call-process-region ,vec (point-min) (point-max)
                    (car (split-string ,compress)) t t nil
                    (cdr (split-string ,compress)))))
            `(lambda (beg end)
               (let ((coding-system-for-write 'binary)
-                    (coding-system-for-read 'binary)
-                    (default-directory
-                      (tramp-compat-temporary-file-directory)))
+                    (coding-system-for-read 'binary))
                 (apply
                  'tramp-call-process-region ,vec beg end
                  (car (split-string ,compress)) t t nil
index e3755533b9dd4e4b4efcc55811c608f205800821..b02760bff8078fa93fb060de4515c4dfcfc7af14 100644 (file)
@@ -3445,7 +3445,7 @@ The terminal type can be configured with `tramp-terminal-type'."
                 (tramp-message vec 3 "Process has finished.")
                 (throw 'tramp-action 'ok))
             (tramp-message vec 3 "Process has died.")
-            (throw 'tramp-action 'process-died))))
+            (throw 'tramp-action 'out-of-band-failed))))
        (t nil)))
 
 ;;; Functions for processing the actions:
@@ -3506,6 +3506,10 @@ connection buffer."
           (tramp-get-connection-buffer vec) vec 'file-error
           (cond
            ((eq exit 'permission-denied) "Permission denied")
+           ((eq exit 'out-of-band-failed)
+            (format-message
+             "Copy failed, see buffer `%s' for details"
+             (tramp-get-connection-buffer vec)))
            ((eq exit 'process-died)
              (substitute-command-keys
               (concat
@@ -4003,7 +4007,8 @@ ALIST is of the form ((FROM . TO) ...)."
 It always returns a return code.  The Lisp error raised when
 PROGRAM is nil is trapped also, returning 1.  Furthermore, traces
 are written with verbosity of 6."
-  (let ((v (or vec
+  (let ((default-directory  (tramp-compat-temporary-file-directory))
+       (v (or vec
               (vector tramp-current-method tramp-current-user
                       tramp-current-host nil nil)))
        (destination (if (eq destination t) (current-buffer) destination))
@@ -4033,7 +4038,8 @@ are written with verbosity of 6."
 It always returns a return code.  The Lisp error raised when
 PROGRAM is nil is trapped also, returning 1.  Furthermore, traces
 are written with verbosity of 6."
-  (let ((v (or vec
+  (let ((default-directory  (tramp-compat-temporary-file-directory))
+       (v (or vec
               (vector tramp-current-method tramp-current-user
                       tramp-current-host nil nil)))
        (buffer (if (eq buffer t) (current-buffer) buffer))