(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
;; both files, we invoke `cp' or `mv' on the remote
;; host directly.
((tramp-equal-remote filename newname)
+ (setq copy-keep-date
+ (or (eq op 'rename) keep-date preserve-uid-gid))
(tramp-do-copy-or-rename-file-directly
op filename newname
ok-if-already-exists keep-date preserve-uid-gid))
((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))
(cond
;; Fast track on local machine.
((tramp-local-host-p v)
+ (setq copy-keep-date
+ (or (eq op 'rename) keep-date preserve-uid-gid))
(tramp-do-copy-or-rename-file-directly
op filename newname
ok-if-already-exists keep-date preserve-uid-gid))
;; 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))
;; 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.
(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)))
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")
+ (let* ((cmd (cond ((and (eq op 'copy) (or keep-date preserve-uid-gid))
+ "cp -f -p")
((eq op 'copy) "cp -f")
((eq op 'rename) "mv -f")
(t (tramp-error
(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)
(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 (string-empty-p (tramp-scp-direct-remote-copying v1 v2)))
?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
;; 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)