Subject: Re: bug#68805: 29.2; Tramp: out-of-band copy-file fails when tramp-copy-keep-date is nil

From: Sean Devlin <[email-masked]>
Date: Thu, 1 Feb 2024 10:34:36 -0500

Hi Michael,

I can confirm the below patch fixes the issue. Thanks for your help!

Regarding the comment, couldn’t some cached file properties (i.e. other than
file-exists-p) be wrong even if NEWNAME did already exist? I haven’t really
thought this through, just curious.

Thanks!

> On Feb 1, 2024, at 8:49 AM, Michael Albinus <[email-masked]> wrote:
> 
> Michael Albinus via "Bug reports for GNU Emacs, the Swiss army knife of
> text editors" <[email-masked]> writes:
> 
> Hi Sean,
> 
>> Thanks for the report and the analysis. It is correct. Could you please
>> check, whether this patch fixes it:
> 
> Oops, that's too lax. Pls try the following instead:
> 
> diff --git a/lisp/tramp-sh.el b/lisp/tramp-sh.el
> index 1301cd63..44c0bdc7 100644
> --- a/lisp/tramp-sh.el
> +++ b/lisp/tramp-sh.el
> @@ -2521,6 +2521,12 @@ The method used must be an out-of-band method."
> 	    ;; cached password).
> 	    (tramp-cleanup-connection v 'keep-debug 'keep-password))))
> 
> +      ;; The cached file properties might be wrong if NEWNAME didn't
> +      ;; exist.  Flush them.
> +      (when v2
> +	(with-parsed-tramp-file-name newname v2
> +	  (tramp-flush-file-properties v2 v2-localname)))
> +
>       ;; Handle KEEP-DATE argument.
>       (when (and keep-date (not copy-keep-date))
> 	(tramp-compat-set-file-times
> 
> Best regards, Michael.