[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 9878cf4 1/2: Improve robustness for out-of-band cop
From: |
Michael Albinus |
Subject: |
[Emacs-diffs] master 9878cf4 1/2: Improve robustness for out-of-band copy in Tramp |
Date: |
Tue, 31 May 2016 18:01:38 +0000 (UTC) |
branch: master
commit 9878cf4d30589eed27ea609de3ebd9cb9c72d41f
Author: Michael Albinus <address@hidden>
Commit: Michael Albinus <address@hidden>
Improve robustness for out-of-band copy in Tramp
* 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 | 2 +-
lisp/net/tramp-cmds.el | 2 +-
lisp/net/tramp-gvfs.el | 2 +-
lisp/net/tramp-sh.el | 51 ++++++++++++++----------------------------------
lisp/net/tramp.el | 12 +++++++++---
5 files changed, 27 insertions(+), 42 deletions(-)
diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el
index 1281dbb..f77e44e 100644
--- a/lisp/net/tramp-adb.el
+++ b/lisp/net/tramp-adb.el
@@ -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
diff --git a/lisp/net/tramp-cmds.el b/lisp/net/tramp-cmds.el
index 856011f..45f3004 100644
--- a/lisp/net/tramp-cmds.el
+++ b/lisp/net/tramp-cmds.el
@@ -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)
diff --git a/lisp/net/tramp-gvfs.el b/lisp/net/tramp-gvfs.el
index ac390e5..0e874d6 100644
--- a/lisp/net/tramp-gvfs.el
+++ b/lisp/net/tramp-gvfs.el
@@ -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))))
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index e9f78b7..19f687c 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -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
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index e375553..b02760b 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -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))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master 9878cf4 1/2: Improve robustness for out-of-band copy in Tramp,
Michael Albinus <=