Dan Davison <davi...@stats.ox.ac.uk> writes:

Hi Dan,

> 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?

`tramp-cleanup-connection' is too heavy, because it also disconnects the
remote host. Reestablishing the connection is expansive, compared with
basic file operations.

What you need is just flushing the file cache. Something like

  (if (file-remote-p default-directory)
      (with-parsed-tramp-file-name default-directory nil
        (tramp-flush-directory-property v "")))

With Tramp 2.1.19, released recently, this isn't needed anymore. File
cache flushing is applied in `tramp-handle-process-file', the working
horse for all synchronous remote process calls.

> Thanks,
>
> Dan

Best regards, Michael.

_______________________________________________
Tramp-devel mailing list
Tramp-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/tramp-devel

Reply via email to