It seems that file-exists-p sometimes requires `tramp-cleanup-connection' to be executed in order for its return value to be reliable. Specifically, if I create the file in a way that tramp does not know about, then tramp may report that the file does not exist when it does[1].
I am using (if (file-remote-p default-directory) (tramp-cleanup-connection default-directory)) to accomplish this cache flushing. Is it reasonable to pass the connection as string to tramp-cleanup-connection like that? Or should I create the argument in some different way? Or is there a different way to ensure that file-exists-p reports the correct answer? Thanks, Dan Footnotes: [1] In testing I have done this by creating the file in a separate ssh session, outside emacs. But the use case that I am working on involves the file being created by an emacs comint process. Here's my test code: (defun user-create (&optional flush) (let* ((default-directory "/davi...@oak.well.ox.ac.uk:") (localname "/tmp/tramp-test") (tmp-file (concat (file-remote-p default-directory) localname))) (shell-command (format "rm -f %s" localname)) (tramp-cleanup-all-connections) (insert "\n------------\n") (insert (format "file is %s\n" tmp-file)) (insert (format "file exists?\t%S\n" (file-exists-p tmp-file))) (insert (format "go create %s now!\n" tmp-file)) (sit-for 7) (if flush (tramp-cleanup-connection default-directory)) (insert (format "file exists?\t%S\n" (file-exists-p tmp-file))) (insert "------------\n"))) (user-create) ------------ file is /scp:davi...@oak.well.ox.ac.uk:/tmp/tramp-test file exists? nil go create /scp:davi...@oak.well.ox.ac.uk:/tmp/tramp-test now! file exists? nil ------------ (user-create 'flush) ------------ file is /scp:davi...@oak.well.ox.ac.uk:/tmp/tramp-test file exists? nil go create /scp:davi...@oak.well.ox.ac.uk:/tmp/tramp-test now! file exists? t ------------ _______________________________________________ Tramp-devel mailing list Tramp-devel@gnu.org http://lists.gnu.org/mailman/listinfo/tramp-devel