]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix Tramp mount-spec
authorMichael Albinus <michael.albinus@gmx.de>
Mon, 26 Jun 2023 13:48:48 +0000 (15:48 +0200)
committerMichael Albinus <michael.albinus@gmx.de>
Mon, 26 Jun 2023 13:48:48 +0000 (15:48 +0200)
* 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
lisp/net/tramp-rclone.el

index 99360c2c28e14ca7c771999651f0c16f08a589ba..aadc64666a53ffde2a5d79e5942a6c440cac2351 100644 (file)
@@ -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
index 02e96e104384676c670fec75792393f31e666dab..f71e4f732e22c1c49a143a1876c244faa8ba2a1b 100644 (file)
@@ -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)