summaryrefslogtreecommitdiff
path: root/lisp/net/tramp-smb.el
diff options
context:
space:
mode:
authorMichael Albinus <michael.albinus@gmx.de>2017-08-27 19:16:58 +0200
committerMichael Albinus <michael.albinus@gmx.de>2017-08-27 19:16:58 +0200
commit79cc9445e182ad5d80380ccf677b947d76854ce8 (patch)
tree359b39b95760f6c1907fc9aeafff662e997b04b8 /lisp/net/tramp-smb.el
parentc99507645a2dbcb08224c8075bc6675dd1b09bbc (diff)
downloademacs-79cc9445e182ad5d80380ccf677b947d76854ce8.tar.gz
emacs-79cc9445e182ad5d80380ccf677b947d76854ce8.tar.bz2
emacs-79cc9445e182ad5d80380ccf677b947d76854ce8.zip
Tramp cleanup
* lisp/net/tramp-sh.el (tramp-sh-extra-args): Remove compat code. (tramp-sh-handle-make-symbolic-link): More robust check for TARGET remoteness. * lisp/net/tramp-smb.el (tramp-smb-handle-copy-directory): Disable copying by tar temporarily, it doesn't work reliably. (tramp-smb-do-file-attributes-with-stat): Resolve symlink. (tramp-smb-handle-make-symbolic-link): Fix implementation. * lisp/net/tramp.el (tramp-handle-file-symlink-p): Simplify. * test/lisp/net/tramp-tests.el (tramp-test21-file-links): Extend test.
Diffstat (limited to 'lisp/net/tramp-smb.el')
-rw-r--r--lisp/net/tramp-smb.el87
1 files changed, 47 insertions, 40 deletions
diff --git a/lisp/net/tramp-smb.el b/lisp/net/tramp-smb.el
index f734b80d535..920e10331ba 100644
--- a/lisp/net/tramp-smb.el
+++ b/lisp/net/tramp-smb.el
@@ -430,7 +430,8 @@ pass to the OPERATION."
(delete-directory tmpdir 'recursive))))
;; We can copy recursively.
- ((and (or t1 t2) (tramp-smb-get-cifs-capabilities v))
+ ;; Does not work reliably.
+ (nil ;(and (or t1 t2) (tramp-smb-get-cifs-capabilities v))
(when (and (file-directory-p newname)
(not (string-equal (file-name-nondirectory dirname)
(file-name-nondirectory newname))))
@@ -888,6 +889,16 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
(string-to-number (match-string 2)) ;; month
(string-to-number (match-string 1)))))) ;; year
(forward-line))
+
+ ;; Resolve symlink.
+ (when (and (stringp id)
+ (tramp-smb-send-command
+ vec
+ (format "readlink \"%s\"" (tramp-smb-get-localname vec))))
+ (goto-char (point-min))
+ (and (looking-at ".+ -> \\(.+\\)")
+ (setq id (match-string 1))))
+
;; Return the result.
(list id link uid gid atime mtime ctime size mode nil inode
(tramp-get-device vec)))))))
@@ -1105,47 +1116,43 @@ component is used as the target of the symlink."
(tramp-run-real-handler
'make-symbolic-link (list target linkname ok-if-already-exists))
- (unless (tramp-equal-remote target linkname)
- (with-parsed-tramp-file-name
- (if (tramp-tramp-file-p target) target linkname) nil
+ (with-parsed-tramp-file-name linkname nil
+ ;; Do the 'confirm if exists' thing.
+ (when (file-exists-p linkname)
+ ;; What to do?
+ (if (or (null ok-if-already-exists) ; not allowed to exist
+ (and (numberp ok-if-already-exists)
+ (not (yes-or-no-p
+ (format
+ "File %s already exists; make it a link anyway? "
+ localname)))))
+ (tramp-error v 'file-already-exists localname)
+ (delete-file linkname)))
+
+ (unless (tramp-smb-get-cifs-capabilities v)
+ (tramp-error v 'file-error "make-symbolic-link not supported"))
+
+ ;; If TARGET is a Tramp name, use just the localname component.
+ (when (and (tramp-tramp-file-p target)
+ (tramp-file-name-equal-p
+ v (tramp-dissect-file-name (expand-file-name target))))
+ (setq target
+ (tramp-file-name-localname
+ (tramp-dissect-file-name (expand-file-name target)))))
+
+ ;; We must also flush the cache of the directory, because
+ ;; `file-attributes' reads the values from there.
+ (tramp-flush-file-property v (file-name-directory localname))
+ (tramp-flush-file-property v localname)
+
+ (unless
+ (tramp-smb-send-command
+ v
+ (format "symlink \"%s\" \"%s\"" target (tramp-smb-get-localname v)))
(tramp-error
v 'file-error
- "make-symbolic-link: %s"
- "only implemented for same method, same user, same host")))
- (with-parsed-tramp-file-name target v1
- (with-parsed-tramp-file-name linkname v2
- (when (file-directory-p target)
- (tramp-error
- v2 'file-error
- "make-symbolic-link: %s must not be a directory" target))
- ;; Do the 'confirm if exists' thing.
- (when (file-exists-p linkname)
- ;; What to do?
- (if (or (null ok-if-already-exists) ; not allowed to exist
- (and (numberp ok-if-already-exists)
- (not (yes-or-no-p
- (format
- "File %s already exists; make it a link anyway? "
- v2-localname)))))
- (tramp-error v2 'file-already-exists v2-localname)
- (delete-file linkname)))
- (unless (tramp-smb-get-cifs-capabilities v1)
- (tramp-error v2 'file-error "make-symbolic-link not supported"))
- ;; We must also flush the cache of the directory, because
- ;; `file-attributes' reads the values from there.
- (tramp-flush-file-property v2 (file-name-directory v2-localname))
- (tramp-flush-file-property v2 v2-localname)
- (unless
- (tramp-smb-send-command
- v1
- (format
- "symlink \"%s\" \"%s\""
- (tramp-smb-get-localname v1)
- (tramp-smb-get-localname v2)))
- (tramp-error
- v2 'file-error
- "error with make-symbolic-link, see buffer `%s' for details"
- (buffer-name)))))))
+ "error with make-symbolic-link, see buffer `%s' for details"
+ (buffer-name))))))
(defun tramp-smb-handle-process-file
(program &optional infile destination display &rest args)