Subject: bug#30533: 26.0.60; (copy-file) over TRAMP FTP mistakes file for directory

From: Michael Albinus <[email-masked]>
Date: Tue, 20 Feb 2018 16:06:41 +0100

Christian Johansson <[email-masked]> writes:

Hi Chrsitian,

> I have a case where Emacs have trouble understanding whether a remote
> file is a file or a directory, I run this code where PATH-LOCAL is on
> localhost and PATH-REMOTE is on a remote FTP via TRAMP
>
> (let ((file-or-directory (not (file-directory-p path-remote))))
>     (if file-or-directory
>         (progn
>           (message "Downloading file '%s' to '%s'.. (synchronously)" path-remote path-local)
>           (copy-file path-remote path-local t t t t)
>           (message "Download of file '%s' finished. (synchronously)" path-local))
>       (progn
>         (message "Downloading directory '%s' to '%s'.. (synchronously)" path-remote path-local)
>         (copy-directory path-remote path-local t t t)
>         (message "Download of directory '%s' finished. (synchronously)"
>     path-local))))
>
> The file .error-log will be transferred locally to .error-log/.error-log
> instead of .error-log. The filename does not matter.
>
> It seems (file-regular-p) mistakes remote files over TRAMP FTP more
> often than (file-directory-p). Maybe that is the cause of this problem.

I have problems in reproducing the scenario. Coul you, pls, give
examples of PATH-LOCAL and PATH-REMOTE?

It is also important to know, whether PATH-LOCAL is an existing file or
directory. Also, in case of a directory, it is important to know,
whether the string PATH_LOCAL has a trailing slash.

Thanks, and best regards, Michael.