aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2017-06-10 10:57:19 +0200
committerMichael Albinus2017-06-10 10:57:19 +0200
commitf361c54e6abc5ba5fa5ce6cc9734b5283e0e6aa3 (patch)
tree58e1c37cf5f3d53275fa4e4d30decd6fd3d1f31d
parent1a3feb8eade24eaff6dcd9edc032cfcd35e41dd7 (diff)
downloademacs-f361c54e6abc5ba5fa5ce6cc9734b5283e0e6aa3.tar.gz
emacs-f361c54e6abc5ba5fa5ce6cc9734b5283e0e6aa3.zip
Fix domain port and handling in tramp-gvfs.el
* lisp/net/tramp-gvfs.el (tramp-gvfs-dbus-byte-array-to-string): Return nil if BYTE-ARRAY is nil. (tramp-gvfs-url-file-name, tramp-gvfs-handler-mounted-unmounted) (tramp-gvfs-connection-mounted-p, tramp-gvfs-mount-spec): Fix domain and port handling. * lisp/net/tramp.el (tramp-handle-file-name-case-insensitive-p): Ignore errors.
-rw-r--r--lisp/net/tramp-gvfs.el37
-rw-r--r--lisp/net/tramp.el75
2 files changed, 54 insertions, 58 deletions
diff --git a/lisp/net/tramp-gvfs.el b/lisp/net/tramp-gvfs.el
index d031c73c3f7..119efa53f36 100644
--- a/lisp/net/tramp-gvfs.el
+++ b/lisp/net/tramp-gvfs.el
@@ -562,14 +562,16 @@ pass to the OPERATION."
562 (concat string (string 0)) string))) 562 (concat string (string 0)) string)))
563 563
564(defun tramp-gvfs-dbus-byte-array-to-string (byte-array) 564(defun tramp-gvfs-dbus-byte-array-to-string (byte-array)
565 "Like `dbus-byte-array-to-string' but remove trailing \\0 if exists." 565 "Like `dbus-byte-array-to-string' but remove trailing \\0 if exists.
566Return nil for null BYTE-ARRAY."
566 ;; The byte array could be a variant. Take care. 567 ;; The byte array could be a variant. Take care.
567 (let ((byte-array 568 (let ((byte-array
568 (if (and (consp byte-array) (atom (car byte-array))) 569 (if (and (consp byte-array) (atom (car byte-array)))
569 byte-array (car byte-array)))) 570 byte-array (car byte-array))))
570 (dbus-byte-array-to-string 571 (and byte-array
571 (if (and (consp byte-array) (zerop (car (last byte-array)))) 572 (dbus-byte-array-to-string
572 (butlast byte-array) byte-array)))) 573 (if (and (consp byte-array) (zerop (car (last byte-array))))
574 (butlast byte-array) byte-array)))))
573 575
574(defun tramp-gvfs-stringify-dbus-message (message) 576(defun tramp-gvfs-stringify-dbus-message (message)
575 "Convert a D-Bus message into readable UTF8 strings, used for traces." 577 "Convert a D-Bus message into readable UTF8 strings, used for traces."
@@ -815,8 +817,7 @@ file names."
815 ;; `expand-file-name' (this does "/./" and "/../"). 817 ;; `expand-file-name' (this does "/./" and "/../").
816 (tramp-make-tramp-file-name 818 (tramp-make-tramp-file-name
817 method user domain host port 819 method user domain host port
818 (tramp-run-real-handler 820 (tramp-run-real-handler 'expand-file-name (list localname))))))
819 'expand-file-name (list localname))))))
820 821
821(defun tramp-gvfs-get-directory-attributes (directory) 822(defun tramp-gvfs-get-directory-attributes (directory)
822 "Return GVFS attributes association list of all files in DIRECTORY." 823 "Return GVFS attributes association list of all files in DIRECTORY."
@@ -1227,12 +1228,11 @@ file-notify events."
1227 (with-parsed-tramp-file-name filename nil 1228 (with-parsed-tramp-file-name filename nil
1228 (when (string-equal "gdrive" method) 1229 (when (string-equal "gdrive" method)
1229 (setq method "google-drive")) 1230 (setq method "google-drive"))
1230 (when (and user (string-match tramp-user-with-domain-regexp user)) 1231 (when (and user domain)
1231 (setq user 1232 (setq user (concat domain ";" user)))
1232 (concat (match-string 2 user) ";" (match-string 1 user))))
1233 (url-parse-make-urlobj 1233 (url-parse-make-urlobj
1234 method (and user (url-hexify-string user)) nil 1234 method (and user (url-hexify-string user)) nil host
1235 (tramp-file-name-host v) (tramp-file-name-port v) 1235 (if (stringp port) (string-to-number port) port)
1236 (and localname (url-hexify-string localname)) nil nil t)) 1236 (and localname (url-hexify-string localname)) nil nil t))
1237 (url-parse-make-urlobj 1237 (url-parse-make-urlobj
1238 "file" nil nil nil nil 1238 "file" nil nil nil nil
@@ -1398,10 +1398,6 @@ ADDRESS can have the form \"xx:xx:xx:xx:xx:xx\" or \"[xx:xx:xx:xx:xx:xx]\"."
1398 (setq method "davs")) 1398 (setq method "davs"))
1399 (when (string-equal "google-drive" method) 1399 (when (string-equal "google-drive" method)
1400 (setq method "gdrive")) 1400 (setq method "gdrive"))
1401 (unless (zerop (length domain))
1402 (setq user (concat user tramp-prefix-domain-format domain)))
1403 (unless (zerop (length port))
1404 (setq host (concat host tramp-prefix-port-format port)))
1405 (with-parsed-tramp-file-name 1401 (with-parsed-tramp-file-name
1406 (tramp-make-tramp-file-name method user domain host port "") nil 1402 (tramp-make-tramp-file-name method user domain host port "") nil
1407 (tramp-message 1403 (tramp-message
@@ -1487,14 +1483,12 @@ ADDRESS can have the form \"xx:xx:xx:xx:xx:xx\" or \"[xx:xx:xx:xx:xx:xx]\"."
1487 (setq method "gdrive")) 1483 (setq method "gdrive"))
1488 (when (and (string-equal "synce" method) (zerop (length user))) 1484 (when (and (string-equal "synce" method) (zerop (length user)))
1489 (setq user (or (tramp-file-name-user vec) ""))) 1485 (setq user (or (tramp-file-name-user vec) "")))
1490 (unless (zerop (length domain))
1491 (setq user (concat user tramp-prefix-domain-format domain)))
1492 (unless (zerop (length port))
1493 (setq host (concat host tramp-prefix-port-format port)))
1494 (when (and 1486 (when (and
1495 (string-equal method (tramp-file-name-method vec)) 1487 (string-equal method (tramp-file-name-method vec))
1496 (string-equal user (or (tramp-file-name-user vec) "")) 1488 (string-equal user (tramp-file-name-user vec))
1489 (string-equal domain (tramp-file-name-domain vec))
1497 (string-equal host (tramp-file-name-host vec)) 1490 (string-equal host (tramp-file-name-host vec))
1491 (string-equal port (tramp-file-name-port vec))
1498 (string-match (concat "^" (regexp-quote prefix)) 1492 (string-match (concat "^" (regexp-quote prefix))
1499 (tramp-file-name-unquote-localname vec))) 1493 (tramp-file-name-unquote-localname vec)))
1500 ;; Set prefix, mountpoint and location. 1494 ;; Set prefix, mountpoint and location.
@@ -1554,8 +1548,7 @@ It was \"a(say)\", but has changed to \"a{sv})\"."
1554 ,@(when domain 1548 ,@(when domain
1555 (list (tramp-gvfs-mount-spec-entry "domain" domain))) 1549 (list (tramp-gvfs-mount-spec-entry "domain" domain)))
1556 ,@(when port 1550 ,@(when port
1557 (list (tramp-gvfs-mount-spec-entry 1551 (list (tramp-gvfs-mount-spec-entry "port" port)))))
1558 "port" (number-to-string port))))))
1559 (mount-pref 1552 (mount-pref
1560 (if (and (string-match "\\`dav" method) 1553 (if (and (string-match "\\`dav" method)
1561 (string-match "^/?[^/]+" localname)) 1554 (string-match "^/?[^/]+" localname))
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index 05d197fce08..8758fb61e4a 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -2878,42 +2878,45 @@ User is always nil."
2878 ;; There isn't. So we must check, in case there's a connection already. 2878 ;; There isn't. So we must check, in case there's a connection already.
2879 (and (tramp-connectable-p filename) 2879 (and (tramp-connectable-p filename)
2880 (with-tramp-connection-property v "case-insensitive" 2880 (with-tramp-connection-property v "case-insensitive"
2881 (with-tramp-progress-reporter v 5 "Checking case-insensitive" 2881 (ignore-errors
2882 ;; The idea is to compare a file with lower case letters 2882 (with-tramp-progress-reporter v 5 "Checking case-insensitive"
2883 ;; with the same file with upper case letters. 2883 ;; The idea is to compare a file with lower case
2884 (let ((candidate 2884 ;; letters with the same file with upper case letters.
2885 (tramp-compat-file-name-unquote 2885 (let ((candidate
2886 (directory-file-name filename))) 2886 (tramp-compat-file-name-unquote
2887 tmpfile) 2887 (directory-file-name filename)))
2888 ;; Check, whether we find an existing file with lower 2888 tmpfile)
2889 ;; case letters. This avoids us to create a temporary 2889 ;; Check, whether we find an existing file with
2890 ;; file. 2890 ;; lower case letters. This avoids us to create a
2891 (while (and (string-match 2891 ;; temporary file.
2892 "[a-z]" (file-remote-p candidate 'localname)) 2892 (while (and (string-match
2893 (not (file-exists-p candidate))) 2893 "[a-z]" (file-remote-p candidate 'localname))
2894 (setq candidate 2894 (not (file-exists-p candidate)))
2895 (directory-file-name (file-name-directory candidate)))) 2895 (setq candidate
2896 ;; Nothing found, so we must use a temporary file for 2896 (directory-file-name
2897 ;; comparison. `make-nearby-temp-file' is added to 2897 (file-name-directory candidate))))
2898 ;; Emacs 26+ like `file-name-case-insensitive-p', so 2898 ;; Nothing found, so we must use a temporary file
2899 ;; there is no compatibility problem calling it. 2899 ;; for comparison. `make-nearby-temp-file' is added
2900 (unless 2900 ;; to Emacs 26+ like `file-name-case-insensitive-p',
2901 (string-match "[a-z]" (file-remote-p candidate 'localname)) 2901 ;; so there is no compatibility problem calling it.
2902 (setq tmpfile 2902 (unless
2903 (let ((default-directory 2903 (string-match
2904 (file-name-directory filename))) 2904 "[a-z]" (file-remote-p candidate 'localname))
2905 (tramp-compat-funcall 2905 (setq tmpfile
2906 'make-nearby-temp-file "tramp.")) 2906 (let ((default-directory
2907 candidate tmpfile)) 2907 (file-name-directory filename)))
2908 ;; Check for the existence of the same file with upper 2908 (tramp-compat-funcall
2909 ;; case letters. 2909 'make-nearby-temp-file "tramp."))
2910 (unwind-protect 2910 candidate tmpfile))
2911 (file-exists-p 2911 ;; Check for the existence of the same file with
2912 (concat 2912 ;; upper case letters.
2913 (file-remote-p candidate) 2913 (unwind-protect
2914 (upcase (file-remote-p candidate 'localname)))) 2914 (file-exists-p
2915 ;; Cleanup. 2915 (concat
2916 (when tmpfile (delete-file tmpfile)))))))))) 2916 (file-remote-p candidate)
2917 (upcase (file-remote-p candidate 'localname))))
2918 ;; Cleanup.
2919 (when tmpfile (delete-file tmpfile)))))))))))
2917 2920
2918(defun tramp-handle-file-name-completion 2921(defun tramp-handle-file-name-completion
2919 (filename directory &optional predicate) 2922 (filename directory &optional predicate)