From: Michael Albinus <michael.albinus@gmx.de>
To: Bill Benedetto <bbenedetto@goodyear.com>
Cc: "help-gnu-emacs@gnu.org" <help-gnu-emacs@gnu.org>
Subject: Re: [EXT] Re: Emacs 29 and Tramp and Remote Dired confusion
Date: Fri, 07 Jul 2023 19:30:29 +0200 [thread overview]
Message-ID: <87v8evbpe2.fsf@gmx.de> (raw)
In-Reply-To: <DM4PR18MB419175418EBA6E32AF093768B92DA@DM4PR18MB4191.namprd18.prod.outlook.com> (Bill Benedetto's message of "Fri, 7 Jul 2023 12:58:55 +0000")
[-- Attachment #1: Type: text/plain, Size: 515 bytes --]
Bill Benedetto <bbenedetto@goodyear.com> writes:
> Hello, Michael.
Hi Bill,
> But if I copy within the same remote dired to a new name within that same remote dired, the timestamp changes.
> (Like to make a backup copy of the original file.)
I can reproduce this. And indeed, there is an error in Tramp, a stale
cache. Could you pls test the appended patch?
I'll give it more testing over the weekend, before I push it to the
emacs-29 branch.
> Thanks!
>
> -Bill
Best regards, Michael.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 6073 bytes --]
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index 48ba3d09e3e..cb5907e98a1 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -2061,7 +2061,11 @@ tramp-do-copy-or-rename-file
(t2 (tramp-tramp-file-p newname))
(length (file-attribute-size
(file-attributes (file-truename filename))))
- (msg-operation (if (eq op 'copy) "Copying" "Renaming")))
+ (file-times (file-attribute-modification-time
+ (file-attributes filename)))
+ (file-modes (tramp-default-file-modes filename))
+ (msg-operation (if (eq op 'copy) "Copying" "Renaming"))
+ copy-keep-date)
(with-parsed-tramp-file-name (if t1 filename newname) nil
(unless length
@@ -2094,6 +2098,8 @@ tramp-do-copy-or-rename-file
((and
(tramp-method-out-of-band-p v1 length)
(tramp-method-out-of-band-p v2 length))
+ (setq copy-keep-date
+ (tramp-get-method-parameter v 'tramp-copy-keep-date))
(tramp-do-copy-or-rename-file-out-of-band
op filename newname ok-if-already-exists keep-date))
@@ -2122,6 +2128,8 @@ tramp-do-copy-or-rename-file
;; If the Tramp file has an out-of-band method, the
;; corresponding copy-program can be invoked.
((tramp-method-out-of-band-p v length)
+ (setq copy-keep-date
+ (tramp-get-method-parameter v 'tramp-copy-keep-date))
(tramp-do-copy-or-rename-file-out-of-band
op filename newname ok-if-already-exists keep-date))
@@ -2149,10 +2157,19 @@ tramp-do-copy-or-rename-file
;; When newname did exist, we have wrong cached values.
(when t2
(with-parsed-tramp-file-name newname v2
- (tramp-flush-file-properties v2 v2-localname)))))))))
+ (tramp-flush-file-properties v2 v2-localname)))
+
+ ;; KEEP-DATE handling.
+ (when (and keep-date (not copy-keep-date))
+ (tramp-compat-set-file-times
+ newname file-times (unless ok-if-already-exists 'nofollow)))
+
+ ;; Set the mode.
+ (unless (and keep-date copy-keep-date)
+ (set-file-modes newname file-modes))))))))
(defun tramp-do-copy-or-rename-file-via-buffer
- (op filename newname ok-if-already-exists keep-date)
+ (op filename newname _ok-if-already-exists _keep-date)
"Use an Emacs buffer to copy or rename a file.
First arg OP is either `copy' or `rename' and indicates the operation.
FILENAME is the source file, NEWNAME the target file.
@@ -2179,14 +2196,7 @@ tramp-do-copy-or-rename-file-via-buffer
(with-temp-file newname
(set-buffer-multibyte nil)
(insert-file-contents-literally filename)))
- ;; KEEP-DATE handling.
- (when keep-date
- (tramp-compat-set-file-times
- newname
- (file-attribute-modification-time (file-attributes filename))
- (unless ok-if-already-exists 'nofollow)))
- ;; Set the mode.
- (set-file-modes newname (tramp-default-file-modes filename))
+
;; If the operation was `rename', delete the original file.
(unless (eq op 'copy) (delete-file filename)))
@@ -2202,10 +2212,7 @@ tramp-do-copy-or-rename-file-directly
the uid and gid from FILENAME."
;; FILENAME and NEWNAME are already expanded.
(let ((t1 (tramp-tramp-file-p filename))
- (t2 (tramp-tramp-file-p newname))
- (file-times (file-attribute-modification-time
- (file-attributes filename)))
- (file-modes (tramp-default-file-modes filename)))
+ (t2 (tramp-tramp-file-p newname)))
(with-parsed-tramp-file-name (if t1 filename newname) nil
(let* ((cmd (cond ((and (eq op 'copy) preserve-uid-gid) "cp -f -p")
((eq op 'copy) "cp -f")
@@ -2336,14 +2343,7 @@ tramp-do-copy-or-rename-file-directly
(list tmpfile localname2 ok-if-already-exists)))))
;; Save exit.
- (ignore-errors (delete-file tmpfile)))))))))
-
- ;; Set the time and mode. Mask possible errors.
- (ignore-errors
- (when keep-date
- (tramp-compat-set-file-times
- newname file-times (unless ok-if-already-exists 'nofollow))
- (set-file-modes newname file-modes))))))
+ (ignore-errors (delete-file tmpfile))))))))))))
(defun tramp-do-copy-or-rename-file-out-of-band
(op filename newname ok-if-already-exists keep-date)
@@ -2355,7 +2355,7 @@ tramp-do-copy-or-rename-file-out-of-band
(v2 (and (tramp-tramp-file-p newname)
(tramp-dissect-file-name newname)))
(v (or v1 v2))
- copy-program copy-args copy-env copy-keep-date listener spec
+ copy-program copy-args copy-env listener spec
options source target remote-copy-program remote-copy-args p)
(if (and v1 v2 (zerop (length (tramp-scp-direct-remote-copying v1 v2))))
@@ -2427,8 +2427,6 @@ tramp-do-copy-or-rename-file-out-of-band
?y (tramp-scp-force-scp-protocol v)
?z (tramp-scp-direct-remote-copying v1 v2))
copy-program (tramp-get-method-parameter v 'tramp-copy-program)
- copy-keep-date (tramp-get-method-parameter
- v 'tramp-copy-keep-date)
copy-args
;; " " has either been a replacement of "%k" (when
;; keep-date argument is non-nil), or a replacement for
@@ -2536,19 +2534,7 @@ tramp-do-copy-or-rename-file-out-of-band
;; Houston, we have a problem! Likely, the listener is
;; still running, so let's clear everything (but the
;; cached password).
- (tramp-cleanup-connection v 'keep-debug 'keep-password))))
-
- ;; Handle KEEP-DATE argument.
- (when (and keep-date (not copy-keep-date))
- (tramp-compat-set-file-times
- newname
- (file-attribute-modification-time (file-attributes filename))
- (unless ok-if-already-exists 'nofollow)))
-
- ;; Set the mode.
- (unless (and keep-date copy-keep-date)
- (ignore-errors
- (set-file-modes newname (tramp-default-file-modes filename)))))
+ (tramp-cleanup-connection v 'keep-debug 'keep-password)))))
;; If the operation was `rename', delete the original file.
(unless (eq op 'copy)
next prev parent reply other threads:[~2023-07-07 17:30 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-07 12:14 Emacs 29 and Tramp and Remote Dired confusion Bill Benedetto
2023-07-07 12:39 ` Michael Albinus
2023-07-07 12:58 ` [EXT] " Bill Benedetto
2023-07-07 13:10 ` Eli Zaretskii
2023-07-07 14:42 ` Bill Benedetto
2023-07-07 17:30 ` Michael Albinus [this message]
2023-07-07 17:57 ` [EXT] " Bill Benedetto
2023-07-08 13:50 ` Michael Albinus
2023-07-10 11:23 ` Bill Benedetto
2023-07-07 13:05 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87v8evbpe2.fsf@gmx.de \
--to=michael.albinus@gmx.de \
--cc=bbenedetto@goodyear.com \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).