From 4256123c4673d8b13f9acd6b0e06a80d258f140a Mon Sep 17 00:00:00 2001 From: Michael Albinus Date: Sun, 11 Jun 2023 20:33:34 +0200 Subject: [PATCH] Fix tramp-sshfs * lisp/net/tramp-fuse.el (tramp-fuse-handle-file-exists-p): New defun. (tramp-fuse-mount-timeout): Move up. (tramp-fuse-mount-point): Use `tramp-fuse-mount-timeout'. (tramp-fuse-unmount): Flush "mount-point" file property. * lisp/net/tramp-sshfs.el (tramp-sshfs-file-name-handler-alist): Use `tramp-fuse-handle-file-exists-p'. * test/lisp/net/tramp-tests.el (all): Use function read syntax where appropriate. (tramp-test39-detect-external-change): Let-bind `read-from-minibuffer' instead of `yes-or-no-p'. --- lisp/net/tramp-fuse.el | 32 +++++++++++++++++++------------- lisp/net/tramp-sshfs.el | 2 +- test/lisp/net/tramp-tests.el | 13 +++++++------ 3 files changed, 27 insertions(+), 20 deletions(-) diff --git a/lisp/net/tramp-fuse.el b/lisp/net/tramp-fuse.el index 8626610211a..99360c2c28e 100644 --- a/lisp/net/tramp-fuse.el +++ b/lisp/net/tramp-fuse.el @@ -95,6 +95,11 @@ (with-tramp-file-property v localname "file-executable-p" (file-executable-p (tramp-fuse-local-file-name filename))))) +(defun tramp-fuse-handle-file-exists-p (filename) + "Like `file-exists-p' for Tramp files." + (tramp-skeleton-file-exists-p filename + (file-exists-p (tramp-fuse-local-file-name filename)))) + (defun tramp-fuse-handle-file-name-all-completions (filename directory) "Like `file-name-all-completions' for Tramp files." (tramp-fuse-remove-hidden-files @@ -139,24 +144,24 @@ (format "%s@%s:/" user host) (format "%s:/" host))) -(defun tramp-fuse-mount-point (vec) - "Return local mount point of VEC." - (or (tramp-get-file-property vec "/" "mount-point") - (expand-file-name - (concat - tramp-temp-name-prefix - (tramp-file-name-method vec) "." - (when (tramp-file-name-user vec) - (concat (tramp-file-name-user-domain vec) "@")) - (tramp-file-name-host-port vec)) - (or small-temporary-file-directory - tramp-compat-temporary-file-directory)))) - (defconst tramp-fuse-mount-timeout (eval (car (get 'remote-file-name-inhibit-cache 'standard-value)) t) "Time period to check whether the mount point still exists. It has the same meaning as `remote-file-name-inhibit-cache'.") +(defun tramp-fuse-mount-point (vec) + "Return local mount point of VEC." + (let ((remote-file-name-inhibit-cache tramp-fuse-mount-timeout)) + (or (tramp-get-file-property vec "/" "mount-point") + (expand-file-name + (concat + tramp-temp-name-prefix + (tramp-file-name-method vec) "." + (when (tramp-file-name-user vec) + (concat (tramp-file-name-user-domain vec) "@")) + (tramp-file-name-host-port vec)) + tramp-compat-temporary-file-directory)))) + (defun tramp-fuse-mounted-p (vec) "Check, whether fuse volume determined by VEC is mounted." ;; Remember the mount status by using a file property on "/", @@ -198,6 +203,7 @@ It has the same meaning as `remote-file-name-inhibit-cache'.") (command (format "%s -u %s" (tramp-fuse-get-fusermount) mount-point))) (tramp-message vec 6 "%s\n%s" command (shell-command-to-string command)) (tramp-flush-file-property vec "/" "mounted") + (tramp-flush-file-property vec "/" "mount-point") (setq tramp-fuse-mount-points (delete (tramp-file-name-unify vec) tramp-fuse-mount-points)) ;; Give the caches a chance to expire. diff --git a/lisp/net/tramp-sshfs.el b/lisp/net/tramp-sshfs.el index 9d871276f7a..e3c9e0b53b2 100644 --- a/lisp/net/tramp-sshfs.el +++ b/lisp/net/tramp-sshfs.el @@ -100,7 +100,7 @@ (file-directory-p . tramp-handle-file-directory-p) (file-equal-p . tramp-handle-file-equal-p) (file-executable-p . tramp-fuse-handle-file-executable-p) - (file-exists-p . tramp-handle-file-exists-p) + (file-exists-p . tramp-fuse-handle-file-exists-p) (file-group-gid . tramp-handle-file-group-gid) (file-in-directory-p . tramp-handle-file-in-directory-p) (file-local-copy . tramp-handle-file-local-copy) diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el index 017cb73f3bb..0b01c13470a 100644 --- a/test/lisp/net/tramp-tests.el +++ b/test/lisp/net/tramp-tests.el @@ -2559,7 +2559,7 @@ This checks also `file-name-as-directory', `file-name-directory', ;; Do not overwrite if excluded. (cl-letf (((symbol-function #'y-or-n-p) #'tramp-compat-always) ;; Ange-FTP. - ((symbol-function 'yes-or-no-p) #'tramp-compat-always)) + ((symbol-function #'yes-or-no-p) #'tramp-compat-always)) (write-region "foo" nil tmp-name nil nil nil 'mustbenew)) (should-error (cl-letf (((symbol-function #'y-or-n-p) #'ignore) @@ -6737,8 +6737,9 @@ INPUT, if non-nil, is a string sent to the process." (insert "foo") ;; Bug#53207: with `create-lockfiles' nil, saving the ;; buffer results in a prompt. - (cl-letf (((symbol-function 'yes-or-no-p) - (lambda (_) (ert-fail "Test failed unexpectedly")))) + (cl-letf (((symbol-function #'read-from-minibuffer) + (lambda (&rest _) + (ert-fail "Test failed unexpectedly")))) (should (buffer-modified-p)) (save-buffer) (should-not (buffer-modified-p))) @@ -6756,7 +6757,7 @@ INPUT, if non-nil, is a string sent to the process." ;; modification time properly, for them it doesn't ;; make sense to test. (when (not (verify-visited-file-modtime)) - (cl-letf (((symbol-function 'read-char-choice) + (cl-letf (((symbol-function #'read-char-choice) (lambda (prompt &rest _) (message "%s" prompt) ?y))) (ert-with-message-capture captured-messages (insert "bar") @@ -6772,9 +6773,9 @@ INPUT, if non-nil, is a string sent to the process." (should (file-locked-p tmp-name))))) ;; `save-buffer' removes the file lock. - (cl-letf (((symbol-function 'yes-or-no-p) + (cl-letf (((symbol-function #'yes-or-no-p) #'tramp-compat-always) - ((symbol-function 'read-char-choice) + ((symbol-function #'read-char-choice) (lambda (&rest _) ?y))) (should (buffer-modified-p)) (save-buffer) -- 2.39.2