[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to cleanup connection for file-exists-p

From: Michael Albinus
Subject: Re: How to cleanup connection for file-exists-p
Date: Thu, 26 Aug 2010 09:04:54 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

Dan Davison <address@hidden> 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.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]