From 8eb129a2ca4643a78c7afecc3226f183a1deb143 Mon Sep 17 00:00:00 2001 From: Michael Albinus Date: Mon, 15 May 2023 16:25:23 +0200 Subject: Fix some minor Tramp problems * lisp/net/tramp-crypt.el (tramp-crypt-handle-file-exists-p): New defun. (tramp-crypt-file-name-handler-alist): Add it. * lisp/net/tramp-smb.el (tramp-smb-handle-copy-file): Flush proper file properties. * test/lisp/net/tramp-archive-tests.el (tramp-archive--test-emacs28-p): New defun. (tramp-archive-test48-auto-load): Extend test. --- lisp/net/tramp-crypt.el | 7 ++++++- lisp/net/tramp-smb.el | 10 ++++++---- test/lisp/net/tramp-archive-tests.el | 13 +++++++++++-- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/lisp/net/tramp-crypt.el b/lisp/net/tramp-crypt.el index 276b65fcfb3..9d52966b817 100644 --- a/lisp/net/tramp-crypt.el +++ b/lisp/net/tramp-crypt.el @@ -180,7 +180,7 @@ If NAME doesn't belong to an encrypted remote directory, return nil." (file-directory-p . tramp-handle-file-directory-p) (file-equal-p . tramp-handle-file-equal-p) (file-executable-p . tramp-crypt-handle-file-executable-p) - (file-exists-p . tramp-handle-file-exists-p) + (file-exists-p . tramp-crypt-handle-file-exists-p) ;; `file-group-gid' performed by default-handler. (file-in-directory-p . tramp-handle-file-in-directory-p) (file-local-copy . tramp-handle-file-local-copy) @@ -723,6 +723,11 @@ absolute file names." (let (tramp-crypt-enabled) (file-executable-p (tramp-crypt-encrypt-file-name filename)))) +(defun tramp-crypt-handle-file-exists-p (filename) + "Like `file-exists-p' for Tramp files." + (let (tramp-crypt-enabled) + (file-exists-p (tramp-crypt-encrypt-file-name filename)))) + (defun tramp-crypt-handle-file-locked-p (filename) "Like `file-locked-p' for Tramp files." (let (tramp-crypt-enabled) diff --git a/lisp/net/tramp-smb.el b/lisp/net/tramp-smb.el index 1182501e820..dab85c5160e 100644 --- a/lisp/net/tramp-smb.el +++ b/lisp/net/tramp-smb.el @@ -637,9 +637,6 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored." (not (directory-name-p newname))) (tramp-error v 'file-error "File is a directory %s" newname)) - ;; We must also flush the cache of the directory, because - ;; `file-attributes' reads the values from there. - (tramp-flush-file-properties v localname) (unless (tramp-smb-get-share v) (tramp-error v 'file-error "Target `%s' must contain a share name" newname)) @@ -648,7 +645,12 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored." (tramp-smb-shell-quote-argument filename) (tramp-smb-shell-quote-localname v))) (tramp-error - v 'file-error "Cannot copy `%s' to `%s'" filename newname))))) + v 'file-error "Cannot copy `%s' to `%s'" filename newname)) + + ;; When newname did exist, we have wrong cached values. + (when (tramp-tramp-file-p newname) + (with-parsed-tramp-file-name newname v2 + (tramp-flush-file-properties v2 v2-localname)))))) ;; KEEP-DATE handling. (when keep-date diff --git a/test/lisp/net/tramp-archive-tests.el b/test/lisp/net/tramp-archive-tests.el index 80ec67da8d2..5485b12f74f 100644 --- a/test/lisp/net/tramp-archive-tests.el +++ b/test/lisp/net/tramp-archive-tests.el @@ -121,6 +121,12 @@ the origin of the temporary TMPFILE, have no write permissions." (directory-files tmpfile 'full directory-files-no-dot-files-regexp)) (delete-directory tmpfile))) +(defun tramp-archive--test-emacs28-p () + "Check for Emacs version >= 28.1. +Some semantics has been changed for there, without new functions or +variables, so we check the Emacs version directly." + (>= emacs-major-version 28)) + (ert-deftest tramp-archive-test00-availability () "Test availability of archive file name functions." :expected-result (if tramp-archive-enabled :passed :failed) @@ -912,12 +918,15 @@ This tests also `file-executable-p', `file-writable-p' and `set-file-modes'." (featurep 'tramp-archive))))")) (dolist (enabled '(t nil)) (dolist (default-directory - `(,temporary-file-directory + (append + `(,temporary-file-directory) ;; Starting Emacs in a directory which has ;; `tramp-archive-file-name-regexp' syntax is ;; supported only with Emacs > 27.2 (sigh!). ;; (Bug#48476) - ,(file-name-as-directory tramp-archive-test-directory))) + (and (tramp-archive--test-emacs28-p) + `(,(file-name-as-directory + tramp-archive-test-directory))))) (dolist (file `("/mock::foo" ,(concat tramp-archive-test-archive "foo"))) (should (string-match -- cgit v1.2.1