emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 748b1f1f48e: Fix Tramp mount-spec


From: Michael Albinus
Subject: master 748b1f1f48e: Fix Tramp mount-spec
Date: Mon, 26 Jun 2023 09:49:01 -0400 (EDT)

branch: master
commit 748b1f1f48e28339e5f479a9aaba5eadd9c69ab2
Author: Michael Albinus <michael.albinus@gmx.de>
Commit: Michael Albinus <michael.albinus@gmx.de>

    Fix Tramp mount-spec
    
    * lisp/net/tramp-fuse.el (tramp-fuse-mounted-p): The mount-spec
    could contain an optional trailing slash.  (Bug#64278)
    
    * lisp/net/tramp-rclone.el (tramp-rclone-handle-file-system-info):
    Check return code of command.
---
 lisp/net/tramp-fuse.el   | 13 +++++++++++--
 lisp/net/tramp-rclone.el | 38 +++++++++++++++++++-------------------
 2 files changed, 30 insertions(+), 21 deletions(-)

diff --git a/lisp/net/tramp-fuse.el b/lisp/net/tramp-fuse.el
index 99360c2c28e..aadc64666a5 100644
--- a/lisp/net/tramp-fuse.el
+++ b/lisp/net/tramp-fuse.el
@@ -174,12 +174,21 @@ It has the same meaning as 
`remote-file-name-inhibit-cache'.")
     (or (tramp-get-file-property vec "/" "mounted")
         (let* ((default-directory tramp-compat-temporary-file-directory)
                (command (format "mount -t fuse.%s" (tramp-file-name-method 
vec)))
-              (mount (shell-command-to-string command)))
+              (mount (shell-command-to-string command))
+              (mount-spec (split-string (tramp-fuse-mount-spec vec) ":" 
'omit)))
           (tramp-message vec 6 "%s\n%s" command mount)
+         ;; The mount-spec contains a trailing local file name part,
+         ;; which might not be visible, for example with rclone
+         ;; mounts of type "memory" or "gdrive".  Make it optional.
+         (setq mount-spec
+               (if (cdr mount-spec)
+                   (rx (literal (car mount-spec))
+                       ":" (? (literal (cadr mount-spec))))
+                 (car mount-spec)))
           (tramp-set-file-property
           vec "/" "mounted"
            (when (string-match
-                 (rx bol (group (literal (tramp-fuse-mount-spec vec)))
+                 (rx bol (group (regexp mount-spec))
                      " on " (group (+ (not blank))) blank)
                  mount)
             (tramp-set-file-property
diff --git a/lisp/net/tramp-rclone.el b/lisp/net/tramp-rclone.el
index 02e96e10438..f71e4f732e2 100644
--- a/lisp/net/tramp-rclone.el
+++ b/lisp/net/tramp-rclone.el
@@ -300,25 +300,25 @@ file names."
       (setq filename (file-name-directory filename)))
     (with-parsed-tramp-file-name (expand-file-name filename) nil
       (tramp-message v 5 "file system info: %s" localname)
-      (tramp-rclone-send-command v "about" (concat host ":"))
-      (with-current-buffer (tramp-get-connection-buffer v)
-       (let (total used free)
-         (goto-char (point-min))
-         (while (not (eobp))
-           (when (looking-at (rx "Total: " (+ blank) (group (+ digit))))
-             (setq total (string-to-number (match-string 1))))
-           (when (looking-at (rx "Used: " (+ blank) (group (+ digit))))
-             (setq used (string-to-number (match-string 1))))
-           (when (looking-at (rx "Free: " (+ blank) (group (+ digit))))
-             (setq free (string-to-number (match-string 1))))
-           (forward-line))
-         (when used
-           ;; The used number of bytes is not part of the result.  As
-           ;; side effect, we store it as file property.
-           (tramp-set-file-property v localname "used-bytes" used))
-         ;; Result.
-         (when (and total free)
-           (list total free (- total free))))))))
+      (when (zerop (tramp-rclone-send-command v "about" (concat host ":")))
+        (with-current-buffer (tramp-get-connection-buffer v)
+         (let (total used free)
+           (goto-char (point-min))
+           (while (not (eobp))
+             (when (looking-at (rx "Total: " (+ blank) (group (+ digit))))
+               (setq total (string-to-number (match-string 1))))
+             (when (looking-at (rx "Used: " (+ blank) (group (+ digit))))
+               (setq used (string-to-number (match-string 1))))
+             (when (looking-at (rx "Free: " (+ blank) (group (+ digit))))
+               (setq free (string-to-number (match-string 1))))
+             (forward-line))
+           (when used
+             ;; The used number of bytes is not part of the result.
+             ;; As side effect, we store it as file property.
+             (tramp-set-file-property v localname "used-bytes" used))
+           ;; Result.
+           (when (and total free)
+             (list total free (- total free)))))))))
 
 (defun tramp-rclone-handle-rename-file
   (filename newname &optional ok-if-already-exists)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]