diff options
| author | Michael Albinus | 2020-03-09 16:05:21 +0100 |
|---|---|---|
| committer | Michael Albinus | 2020-03-09 16:05:21 +0100 |
| commit | a1e2a6847007f56d96d0122e493d5228e5c4d08b (patch) | |
| tree | aca427daf304376b8745446c4ba26252a0f7b98c | |
| parent | a461baae79af3cea8780e9d9a845a1e859e96e5e (diff) | |
| download | emacs-a1e2a6847007f56d96d0122e493d5228e5c4d08b.tar.gz emacs-a1e2a6847007f56d96d0122e493d5228e5c4d08b.zip | |
Finish implementation of set-file-times FLAG arg in Tramp
* lisp/net/tramp-adb.el (tramp-adb-handle-set-file-times):
Implement FLAG.
(tramp-adb-handle-copy-file): Adapt `set-file-times' call.
* lisp/net/tramp-compat.el (tramp-compat-set-file-times): New defalias.
* lisp/net/tramp-gvfs.el (tramp-gvfs-handle-set-file-modes)
(tramp-gvfs-handle-set-file-times, tramp-gvfs-set-file-uid-gid):
Simplify `tramp-gvfs-url-file-name' call.
* lisp/net/tramp-sh.el (tramp-sh-handle-set-file-times): Implement FLAG.
(tramp-do-copy-or-rename-file-via-buffer)
(tramp-do-copy-or-rename-file-out-of-band): Add optional argument
OK-IF-ALREADY-EXISTS. Adapt callees.
(tramp-do-copy-or-rename-file-via-buffer)
(tramp-do-copy-or-rename-file-directly)
(tramp-do-copy-or-rename-file-out-of-band): Adapt `set-file-times' call.
* lisp/net/tramp-smb.el (tramp-smb-handle-copy-directory)
(tramp-smb-handle-copy-file): Adapt `set-file-times' call.
* lisp/net/tramp-sudoedit.el (tramp-sudoedit-do-copy-or-rename-file):
Adapt `set-file-times' call.
(tramp-sudoedit-handle-set-file-times): Implement FLAG.
* test/lisp/net/tramp-tests.el (tramp-test22-file-times): Extend test.
| -rw-r--r-- | lisp/net/tramp-adb.el | 16 | ||||
| -rw-r--r-- | lisp/net/tramp-compat.el | 9 | ||||
| -rw-r--r-- | lisp/net/tramp-gvfs.el | 21 | ||||
| -rw-r--r-- | lisp/net/tramp-sh.el | 37 | ||||
| -rw-r--r-- | lisp/net/tramp-smb.el | 7 | ||||
| -rw-r--r-- | lisp/net/tramp-sudoedit.el | 5 | ||||
| -rw-r--r-- | test/lisp/net/tramp-tests.el | 15 |
7 files changed, 65 insertions, 45 deletions
diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el index 7ee740f93cb..bfeaebac2cd 100644 --- a/lisp/net/tramp-adb.el +++ b/lisp/net/tramp-adb.el | |||
| @@ -676,7 +676,6 @@ But handle the case, if the \"test\" command is not available." | |||
| 676 | 676 | ||
| 677 | (defun tramp-adb-handle-set-file-times (filename &optional time flag) | 677 | (defun tramp-adb-handle-set-file-times (filename &optional time flag) |
| 678 | "Like `set-file-times' for Tramp files." | 678 | "Like `set-file-times' for Tramp files." |
| 679 | flag ;; FIXME: Support 'nofollow'. | ||
| 680 | (with-parsed-tramp-file-name filename nil | 679 | (with-parsed-tramp-file-name filename nil |
| 681 | (tramp-flush-file-properties v localname) | 680 | (tramp-flush-file-properties v localname) |
| 682 | (let ((time (if (or (null time) | 681 | (let ((time (if (or (null time) |
| @@ -684,21 +683,22 @@ But handle the case, if the \"test\" command is not available." | |||
| 684 | (tramp-compat-time-equal-p time tramp-time-dont-know)) | 683 | (tramp-compat-time-equal-p time tramp-time-dont-know)) |
| 685 | (current-time) | 684 | (current-time) |
| 686 | time)) | 685 | time)) |
| 686 | (nofollow (if (eq flag 'nofollow) "-h" "")) | ||
| 687 | (quoted-name (tramp-shell-quote-argument localname))) | 687 | (quoted-name (tramp-shell-quote-argument localname))) |
| 688 | ;; Older versions of toybox 'touch' mishandle nanoseconds and/or | 688 | ;; Older versions of toybox 'touch' mishandle nanoseconds and/or |
| 689 | ;; trailing "Z", so fall back on plain seconds if nanoseconds+Z | 689 | ;; trailing "Z", so fall back on plain seconds if nanoseconds+Z |
| 690 | ;; fails. Also, fall back on old POSIX 'touch -t' if 'touch -d' | 690 | ;; fails. Also, fall back on old POSIX 'touch -t' if 'touch -d' |
| 691 | ;; (introduced in POSIX.1-2008) fails. | 691 | ;; (introduced in POSIX.1-2008) fails. |
| 692 | (tramp-adb-send-command-and-check | 692 | (tramp-adb-send-command-and-check |
| 693 | v (format (concat "touch -d %s %s 2>/dev/null || " | 693 | v (format (concat "touch -d %s %s %s 2>/dev/null || " |
| 694 | "touch -d %s %s 2>/dev/null || " | 694 | "touch -d %s %s %s 2>/dev/null || " |
| 695 | "touch -t %s %s") | 695 | "touch -t %s %s %s") |
| 696 | (format-time-string "%Y-%m-%dT%H:%M:%S.%NZ" time t) | 696 | (format-time-string "%Y-%m-%dT%H:%M:%S.%NZ" time t) |
| 697 | quoted-name | 697 | nofollow quoted-name |
| 698 | (format-time-string "%Y-%m-%dT%H:%M:%S" time t) | 698 | (format-time-string "%Y-%m-%dT%H:%M:%S" time t) |
| 699 | quoted-name | 699 | nofollow quoted-name |
| 700 | (format-time-string "%Y%m%d%H%M.%S" time t) | 700 | (format-time-string "%Y%m%d%H%M.%S" time t) |
| 701 | quoted-name))))) | 701 | nofollow quoted-name))))) |
| 702 | 702 | ||
| 703 | (defun tramp-adb-handle-copy-file | 703 | (defun tramp-adb-handle-copy-file |
| 704 | (filename newname &optional ok-if-already-exists keep-date | 704 | (filename newname &optional ok-if-already-exists keep-date |
| @@ -775,7 +775,7 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored." | |||
| 775 | 775 | ||
| 776 | ;; KEEP-DATE handling. | 776 | ;; KEEP-DATE handling. |
| 777 | (when keep-date | 777 | (when keep-date |
| 778 | (set-file-times | 778 | (tramp-compat-set-file-times |
| 779 | newname | 779 | newname |
| 780 | (tramp-compat-file-attribute-modification-time | 780 | (tramp-compat-file-attribute-modification-time |
| 781 | (file-attributes filename)) | 781 | (file-attributes filename)) |
diff --git a/lisp/net/tramp-compat.el b/lisp/net/tramp-compat.el index 8f85550bca0..f0131d59852 100644 --- a/lisp/net/tramp-compat.el +++ b/lisp/net/tramp-compat.el | |||
| @@ -276,7 +276,8 @@ A nil value for either argument stands for the current time." | |||
| 276 | (lambda (reporter &optional value _suffix) | 276 | (lambda (reporter &optional value _suffix) |
| 277 | (progress-reporter-update reporter value)))) | 277 | (progress-reporter-update reporter value)))) |
| 278 | 278 | ||
| 279 | ;; `file-modes' and `set-file-modes' got argument FLAG in Emacs 28.1. | 279 | ;; `file-modes', `set-file-modes' and `set-file-times' got argument |
| 280 | ;; FLAG in Emacs 28.1. | ||
| 280 | (defalias 'tramp-compat-file-modes | 281 | (defalias 'tramp-compat-file-modes |
| 281 | (if (equal (tramp-compat-funcall 'func-arity #'file-modes) '(1 . 2)) | 282 | (if (equal (tramp-compat-funcall 'func-arity #'file-modes) '(1 . 2)) |
| 282 | #'file-modes | 283 | #'file-modes |
| @@ -289,6 +290,12 @@ A nil value for either argument stands for the current time." | |||
| 289 | (lambda (filename mode &optional _flag) | 290 | (lambda (filename mode &optional _flag) |
| 290 | (set-file-modes filename mode)))) | 291 | (set-file-modes filename mode)))) |
| 291 | 292 | ||
| 293 | (defalias 'tramp-compat-set-file-times | ||
| 294 | (if (equal (tramp-compat-funcall 'func-arity #'set-file-times) '(1 . 3)) | ||
| 295 | #'set-file-times | ||
| 296 | (lambda (filename &optional timestamp _flag) | ||
| 297 | (set-file-times filename timestamp)))) | ||
| 298 | |||
| 292 | (add-hook 'tramp-unload-hook | 299 | (add-hook 'tramp-unload-hook |
| 293 | (lambda () | 300 | (lambda () |
| 294 | (unload-feature 'tramp-loaddefs 'force) | 301 | (unload-feature 'tramp-loaddefs 'force) |
diff --git a/lisp/net/tramp-gvfs.el b/lisp/net/tramp-gvfs.el index 1ad57c59a5b..85f28076168 100644 --- a/lisp/net/tramp-gvfs.el +++ b/lisp/net/tramp-gvfs.el | |||
| @@ -1568,23 +1568,21 @@ If FILE-SYSTEM is non-nil, return file system attributes." | |||
| 1568 | (tramp-flush-file-properties v localname) | 1568 | (tramp-flush-file-properties v localname) |
| 1569 | (tramp-gvfs-send-command | 1569 | (tramp-gvfs-send-command |
| 1570 | v "gvfs-set-attribute" (if (eq flag 'nofollow) "-nt" "-t") "uint32" | 1570 | v "gvfs-set-attribute" (if (eq flag 'nofollow) "-nt" "-t") "uint32" |
| 1571 | (tramp-gvfs-url-file-name (tramp-make-tramp-file-name v)) | 1571 | (tramp-gvfs-url-file-name filename) "unix::mode" (number-to-string mode)))) |
| 1572 | "unix::mode" (number-to-string mode)))) | ||
| 1573 | 1572 | ||
| 1574 | (defun tramp-gvfs-handle-set-file-times (filename &optional time flag) | 1573 | (defun tramp-gvfs-handle-set-file-times (filename &optional time flag) |
| 1575 | "Like `set-file-times' for Tramp files." | 1574 | "Like `set-file-times' for Tramp files." |
| 1576 | (with-parsed-tramp-file-name filename nil | 1575 | (with-parsed-tramp-file-name filename nil |
| 1577 | (tramp-flush-file-properties v localname) | 1576 | (tramp-flush-file-properties v localname) |
| 1578 | (let ((time | 1577 | (tramp-gvfs-send-command |
| 1579 | (if (or (null time) | 1578 | v "gvfs-set-attribute" (if (eq flag 'nofollow) "-nt" "-t") "uint64" |
| 1579 | (tramp-gvfs-url-file-name filename) "time::modified" | ||
| 1580 | (format-time-string | ||
| 1581 | "%s" (if (or (null time) | ||
| 1580 | (tramp-compat-time-equal-p time tramp-time-doesnt-exist) | 1582 | (tramp-compat-time-equal-p time tramp-time-doesnt-exist) |
| 1581 | (tramp-compat-time-equal-p time tramp-time-dont-know)) | 1583 | (tramp-compat-time-equal-p time tramp-time-dont-know)) |
| 1582 | (current-time) | 1584 | (current-time) |
| 1583 | time))) | 1585 | time))))) |
| 1584 | (tramp-gvfs-send-command | ||
| 1585 | v "gvfs-set-attribute" (if flag "-nt" "-t") "uint64" | ||
| 1586 | (tramp-gvfs-url-file-name (tramp-make-tramp-file-name v)) | ||
| 1587 | "time::modified" (format-time-string "%s" time))))) | ||
| 1588 | 1586 | ||
| 1589 | (defun tramp-gvfs-set-file-uid-gid (filename &optional uid gid) | 1587 | (defun tramp-gvfs-set-file-uid-gid (filename &optional uid gid) |
| 1590 | "Like `tramp-set-file-uid-gid' for Tramp files." | 1588 | "Like `tramp-set-file-uid-gid' for Tramp files." |
| @@ -1593,12 +1591,11 @@ If FILE-SYSTEM is non-nil, return file system attributes." | |||
| 1593 | (when (natnump uid) | 1591 | (when (natnump uid) |
| 1594 | (tramp-gvfs-send-command | 1592 | (tramp-gvfs-send-command |
| 1595 | v "gvfs-set-attribute" "-t" "uint32" | 1593 | v "gvfs-set-attribute" "-t" "uint32" |
| 1596 | (tramp-gvfs-url-file-name (tramp-make-tramp-file-name v)) | 1594 | (tramp-gvfs-url-file-name filename) "unix::uid" (number-to-string uid))) |
| 1597 | "unix::uid" (number-to-string uid))) | ||
| 1598 | (when (natnump gid) | 1595 | (when (natnump gid) |
| 1599 | (tramp-gvfs-send-command | 1596 | (tramp-gvfs-send-command |
| 1600 | v "gvfs-set-attribute" "-t" "uint32" | 1597 | v "gvfs-set-attribute" "-t" "uint32" |
| 1601 | (tramp-gvfs-url-file-name (tramp-make-tramp-file-name v)) | 1598 | (tramp-gvfs-url-file-name filename) |
| 1602 | "unix::gid" (number-to-string gid))))) | 1599 | "unix::gid" (number-to-string gid))))) |
| 1603 | 1600 | ||
| 1604 | 1601 | ||
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index 560941c4d5b..eaf60554402 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el | |||
| @@ -1500,7 +1500,6 @@ of." | |||
| 1500 | (with-parsed-tramp-file-name filename nil | 1500 | (with-parsed-tramp-file-name filename nil |
| 1501 | (when (tramp-get-remote-touch v) | 1501 | (when (tramp-get-remote-touch v) |
| 1502 | (tramp-flush-file-properties v localname) | 1502 | (tramp-flush-file-properties v localname) |
| 1503 | flag ;; FIXME: Support 'nofollow'. | ||
| 1504 | (let ((time | 1503 | (let ((time |
| 1505 | (if (or (null time) | 1504 | (if (or (null time) |
| 1506 | (tramp-compat-time-equal-p time tramp-time-doesnt-exist) | 1505 | (tramp-compat-time-equal-p time tramp-time-doesnt-exist) |
| @@ -1509,11 +1508,12 @@ of." | |||
| 1509 | time))) | 1508 | time))) |
| 1510 | (tramp-send-command-and-check | 1509 | (tramp-send-command-and-check |
| 1511 | v (format | 1510 | v (format |
| 1512 | "env TZ=UTC %s %s %s" | 1511 | "env TZ=UTC %s %s %s %s" |
| 1513 | (tramp-get-remote-touch v) | 1512 | (tramp-get-remote-touch v) |
| 1514 | (if (tramp-get-connection-property v "touch-t" nil) | 1513 | (if (tramp-get-connection-property v "touch-t" nil) |
| 1515 | (format "-t %s" (format-time-string "%Y%m%d%H%M.%S" time t)) | 1514 | (format "-t %s" (format-time-string "%Y%m%d%H%M.%S" time t)) |
| 1516 | "") | 1515 | "") |
| 1516 | (if (eq flag 'nofollow) "-h" "") | ||
| 1517 | (tramp-shell-quote-argument localname))))))) | 1517 | (tramp-shell-quote-argument localname))))))) |
| 1518 | 1518 | ||
| 1519 | (defun tramp-sh-handle-set-file-uid-gid (filename &optional uid gid) | 1519 | (defun tramp-sh-handle-set-file-uid-gid (filename &optional uid gid) |
| @@ -1979,7 +1979,7 @@ tramp-sh-handle-file-name-all-completions: internal error accessing `%s': `%s'" | |||
| 1979 | (unless (file-directory-p (file-name-directory newname)) | 1979 | (unless (file-directory-p (file-name-directory newname)) |
| 1980 | (make-directory (file-name-directory newname) parents)) | 1980 | (make-directory (file-name-directory newname) parents)) |
| 1981 | (tramp-do-copy-or-rename-file-out-of-band | 1981 | (tramp-do-copy-or-rename-file-out-of-band |
| 1982 | 'copy dirname newname keep-date)) | 1982 | 'copy dirname newname 'ok-if-already-exists keep-date)) |
| 1983 | 1983 | ||
| 1984 | ;; We must do it file-wise. | 1984 | ;; We must do it file-wise. |
| 1985 | (tramp-run-real-handler | 1985 | (tramp-run-real-handler |
| @@ -2075,7 +2075,7 @@ file names." | |||
| 2075 | (tramp-method-out-of-band-p v1 length) | 2075 | (tramp-method-out-of-band-p v1 length) |
| 2076 | (tramp-method-out-of-band-p v2 length)) | 2076 | (tramp-method-out-of-band-p v2 length)) |
| 2077 | (tramp-do-copy-or-rename-file-out-of-band | 2077 | (tramp-do-copy-or-rename-file-out-of-band |
| 2078 | op filename newname keep-date)) | 2078 | op filename newname ok-if-already-exists keep-date)) |
| 2079 | 2079 | ||
| 2080 | ;; No shortcut was possible. So we copy the file | 2080 | ;; No shortcut was possible. So we copy the file |
| 2081 | ;; first. If the operation was `rename', we go back | 2081 | ;; first. If the operation was `rename', we go back |
| @@ -2088,7 +2088,7 @@ file names." | |||
| 2088 | ;; source and target file. | 2088 | ;; source and target file. |
| 2089 | (t | 2089 | (t |
| 2090 | (tramp-do-copy-or-rename-file-via-buffer | 2090 | (tramp-do-copy-or-rename-file-via-buffer |
| 2091 | op filename newname keep-date)))))) | 2091 | op filename newname ok-if-already-exists keep-date)))))) |
| 2092 | 2092 | ||
| 2093 | ;; One file is a Tramp file, the other one is local. | 2093 | ;; One file is a Tramp file, the other one is local. |
| 2094 | ((or t1 t2) | 2094 | ((or t1 t2) |
| @@ -2103,11 +2103,11 @@ file names." | |||
| 2103 | ;; corresponding copy-program can be invoked. | 2103 | ;; corresponding copy-program can be invoked. |
| 2104 | ((tramp-method-out-of-band-p v length) | 2104 | ((tramp-method-out-of-band-p v length) |
| 2105 | (tramp-do-copy-or-rename-file-out-of-band | 2105 | (tramp-do-copy-or-rename-file-out-of-band |
| 2106 | op filename newname keep-date)) | 2106 | op filename newname ok-if-already-exists keep-date)) |
| 2107 | 2107 | ||
| 2108 | ;; Use the inline method via a Tramp buffer. | 2108 | ;; Use the inline method via a Tramp buffer. |
| 2109 | (t (tramp-do-copy-or-rename-file-via-buffer | 2109 | (t (tramp-do-copy-or-rename-file-via-buffer |
| 2110 | op filename newname keep-date)))) | 2110 | op filename newname ok-if-already-exists keep-date)))) |
| 2111 | 2111 | ||
| 2112 | (t | 2112 | (t |
| 2113 | ;; One of them must be a Tramp file. | 2113 | ;; One of them must be a Tramp file. |
| @@ -2129,7 +2129,8 @@ file names." | |||
| 2129 | (with-parsed-tramp-file-name newname v2 | 2129 | (with-parsed-tramp-file-name newname v2 |
| 2130 | (tramp-flush-file-properties v2 v2-localname)))))))) | 2130 | (tramp-flush-file-properties v2 v2-localname)))))))) |
| 2131 | 2131 | ||
| 2132 | (defun tramp-do-copy-or-rename-file-via-buffer (op filename newname keep-date) | 2132 | (defun tramp-do-copy-or-rename-file-via-buffer |
| 2133 | (op filename newname ok-if-already-exists keep-date) | ||
| 2133 | "Use an Emacs buffer to copy or rename a file. | 2134 | "Use an Emacs buffer to copy or rename a file. |
| 2134 | First arg OP is either `copy' or `rename' and indicates the operation. | 2135 | First arg OP is either `copy' or `rename' and indicates the operation. |
| 2135 | FILENAME is the source file, NEWNAME the target file. | 2136 | FILENAME is the source file, NEWNAME the target file. |
| @@ -2157,10 +2158,11 @@ KEEP-DATE is non-nil if NEWNAME should have the same timestamp as FILENAME." | |||
| 2157 | (insert-file-contents-literally filename))) | 2158 | (insert-file-contents-literally filename))) |
| 2158 | ;; KEEP-DATE handling. | 2159 | ;; KEEP-DATE handling. |
| 2159 | (when keep-date | 2160 | (when keep-date |
| 2160 | (set-file-times | 2161 | (tramp-compat-set-file-times |
| 2161 | newname | 2162 | newname |
| 2162 | (tramp-compat-file-attribute-modification-time | 2163 | (tramp-compat-file-attribute-modification-time |
| 2163 | (file-attributes filename)))) | 2164 | (file-attributes filename)) |
| 2165 | (unless ok-if-already-exists 'nofollow))) | ||
| 2164 | ;; Set the mode. | 2166 | ;; Set the mode. |
| 2165 | (set-file-modes newname (tramp-default-file-modes filename)) | 2167 | (set-file-modes newname (tramp-default-file-modes filename)) |
| 2166 | ;; If the operation was `rename', delete the original file. | 2168 | ;; If the operation was `rename', delete the original file. |
| @@ -2314,10 +2316,12 @@ the uid and gid from FILENAME." | |||
| 2314 | ;; Set the time and mode. Mask possible errors. | 2316 | ;; Set the time and mode. Mask possible errors. |
| 2315 | (ignore-errors | 2317 | (ignore-errors |
| 2316 | (when keep-date | 2318 | (when keep-date |
| 2317 | (set-file-times newname file-times) | 2319 | (tramp-compat-set-file-times |
| 2320 | newname file-times (unless ok-if-already-exists 'nofollow)) | ||
| 2318 | (set-file-modes newname file-modes)))))) | 2321 | (set-file-modes newname file-modes)))))) |
| 2319 | 2322 | ||
| 2320 | (defun tramp-do-copy-or-rename-file-out-of-band (op filename newname keep-date) | 2323 | (defun tramp-do-copy-or-rename-file-out-of-band |
| 2324 | (op filename newname ok-if-already-exists keep-date) | ||
| 2321 | "Invoke `scp' program to copy. | 2325 | "Invoke `scp' program to copy. |
| 2322 | The method used must be an out-of-band method." | 2326 | The method used must be an out-of-band method." |
| 2323 | (let* ((t1 (tramp-tramp-file-p filename)) | 2327 | (let* ((t1 (tramp-tramp-file-p filename)) |
| @@ -2340,9 +2344,9 @@ The method used must be an out-of-band method." | |||
| 2340 | (unwind-protect | 2344 | (unwind-protect |
| 2341 | (progn | 2345 | (progn |
| 2342 | (tramp-do-copy-or-rename-file-out-of-band | 2346 | (tramp-do-copy-or-rename-file-out-of-band |
| 2343 | op filename tmpfile keep-date) | 2347 | op filename tmpfile ok-if-already-exists keep-date) |
| 2344 | (tramp-do-copy-or-rename-file-out-of-band | 2348 | (tramp-do-copy-or-rename-file-out-of-band |
| 2345 | 'rename tmpfile newname keep-date)) | 2349 | 'rename tmpfile newname ok-if-already-exists keep-date)) |
| 2346 | ;; Save exit. | 2350 | ;; Save exit. |
| 2347 | (ignore-errors | 2351 | (ignore-errors |
| 2348 | (if dir-flag | 2352 | (if dir-flag |
| @@ -2516,10 +2520,11 @@ The method used must be an out-of-band method." | |||
| 2516 | 2520 | ||
| 2517 | ;; Handle KEEP-DATE argument. | 2521 | ;; Handle KEEP-DATE argument. |
| 2518 | (when (and keep-date (not copy-keep-date)) | 2522 | (when (and keep-date (not copy-keep-date)) |
| 2519 | (set-file-times | 2523 | (tramp-compat-set-file-times |
| 2520 | newname | 2524 | newname |
| 2521 | (tramp-compat-file-attribute-modification-time | 2525 | (tramp-compat-file-attribute-modification-time |
| 2522 | (file-attributes filename)))) | 2526 | (file-attributes filename)) |
| 2527 | (unless ok-if-already-exists 'nofollow))) | ||
| 2523 | 2528 | ||
| 2524 | ;; Set the mode. | 2529 | ;; Set the mode. |
| 2525 | (unless (and keep-date copy-keep-date) | 2530 | (unless (and keep-date copy-keep-date) |
diff --git a/lisp/net/tramp-smb.el b/lisp/net/tramp-smb.el index d91362c879c..effac333dad 100644 --- a/lisp/net/tramp-smb.el +++ b/lisp/net/tramp-smb.el | |||
| @@ -538,10 +538,11 @@ pass to the OPERATION." | |||
| 538 | 538 | ||
| 539 | ;; Handle KEEP-DATE argument. | 539 | ;; Handle KEEP-DATE argument. |
| 540 | (when keep-date | 540 | (when keep-date |
| 541 | (set-file-times | 541 | (tramp-compat-set-file-times |
| 542 | newname | 542 | newname |
| 543 | (tramp-compat-file-attribute-modification-time | 543 | (tramp-compat-file-attribute-modification-time |
| 544 | (file-attributes dirname)))) | 544 | (file-attributes dirname)) |
| 545 | (unless ok-if-already-exists 'nofollow))) | ||
| 545 | 546 | ||
| 546 | ;; Set the mode. | 547 | ;; Set the mode. |
| 547 | (unless keep-date | 548 | (unless keep-date |
| @@ -616,7 +617,7 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored." | |||
| 616 | 617 | ||
| 617 | ;; KEEP-DATE handling. | 618 | ;; KEEP-DATE handling. |
| 618 | (when keep-date | 619 | (when keep-date |
| 619 | (set-file-times | 620 | (tramp-compat-set-file-times |
| 620 | newname | 621 | newname |
| 621 | (tramp-compat-file-attribute-modification-time | 622 | (tramp-compat-file-attribute-modification-time |
| 622 | (file-attributes filename)) | 623 | (file-attributes filename)) |
diff --git a/lisp/net/tramp-sudoedit.el b/lisp/net/tramp-sudoedit.el index c054f405e3d..b6861ba7882 100644 --- a/lisp/net/tramp-sudoedit.el +++ b/lisp/net/tramp-sudoedit.el | |||
| @@ -281,7 +281,8 @@ absolute file names." | |||
| 281 | ;; Set the time and mode. Mask possible errors. | 281 | ;; Set the time and mode. Mask possible errors. |
| 282 | (when keep-date | 282 | (when keep-date |
| 283 | (ignore-errors | 283 | (ignore-errors |
| 284 | (set-file-times newname file-times) | 284 | (tramp-compat-set-file-times |
| 285 | newname file-times (unless ok-if-already-exists 'nofollow)) | ||
| 285 | (set-file-modes newname file-modes))) | 286 | (set-file-modes newname file-modes))) |
| 286 | 287 | ||
| 287 | ;; Handle `preserve-extended-attributes'. We ignore possible | 288 | ;; Handle `preserve-extended-attributes'. We ignore possible |
| @@ -527,7 +528,6 @@ the result will be a local, non-Tramp, file name." | |||
| 527 | "Like `set-file-times' for Tramp files." | 528 | "Like `set-file-times' for Tramp files." |
| 528 | (with-parsed-tramp-file-name filename nil | 529 | (with-parsed-tramp-file-name filename nil |
| 529 | (tramp-flush-file-properties v localname) | 530 | (tramp-flush-file-properties v localname) |
| 530 | flag ;; FIXME: Support 'nofollow'. | ||
| 531 | (let ((time | 531 | (let ((time |
| 532 | (if (or (null time) | 532 | (if (or (null time) |
| 533 | (tramp-compat-time-equal-p time tramp-time-doesnt-exist) | 533 | (tramp-compat-time-equal-p time tramp-time-doesnt-exist) |
| @@ -537,6 +537,7 @@ the result will be a local, non-Tramp, file name." | |||
| 537 | (tramp-sudoedit-send-command | 537 | (tramp-sudoedit-send-command |
| 538 | v "env" "TZ=UTC" "touch" "-t" | 538 | v "env" "TZ=UTC" "touch" "-t" |
| 539 | (format-time-string "%Y%m%d%H%M.%S" time t) | 539 | (format-time-string "%Y%m%d%H%M.%S" time t) |
| 540 | (if (eq flag 'nofollow) "-h" "") | ||
| 540 | (tramp-compat-file-name-unquote localname))))) | 541 | (tramp-compat-file-name-unquote localname))))) |
| 541 | 542 | ||
| 542 | (defun tramp-sudoedit-handle-file-truename (filename) | 543 | (defun tramp-sudoedit-handle-file-truename (filename) |
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el index dcf376e70b4..e220420d8cf 100644 --- a/test/lisp/net/tramp-tests.el +++ b/test/lisp/net/tramp-tests.el | |||
| @@ -3743,8 +3743,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." | |||
| 3743 | (file-attributes tmp-name1)))) | 3743 | (file-attributes tmp-name1)))) |
| 3744 | ;; Skip the test, if the remote handler is not able to set | 3744 | ;; Skip the test, if the remote handler is not able to set |
| 3745 | ;; the correct time. | 3745 | ;; the correct time. |
| 3746 | (skip-unless (set-file-times tmp-name1 (seconds-to-time 1) | 3746 | (skip-unless (set-file-times tmp-name1 (seconds-to-time 1))) |
| 3747 | 'nofollow)) | ||
| 3748 | ;; Dumb remote shells without perl(1) or stat(1) are not | 3747 | ;; Dumb remote shells without perl(1) or stat(1) are not |
| 3749 | ;; able to return the date correctly. They say "don't know". | 3748 | ;; able to return the date correctly. They say "don't know". |
| 3750 | (unless (tramp-compat-time-equal-p | 3749 | (unless (tramp-compat-time-equal-p |
| @@ -3761,7 +3760,17 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." | |||
| 3761 | (should (file-newer-than-file-p tmp-name2 tmp-name1)) | 3760 | (should (file-newer-than-file-p tmp-name2 tmp-name1)) |
| 3762 | ;; `tmp-name3' does not exist. | 3761 | ;; `tmp-name3' does not exist. |
| 3763 | (should (file-newer-than-file-p tmp-name2 tmp-name3)) | 3762 | (should (file-newer-than-file-p tmp-name2 tmp-name3)) |
| 3764 | (should-not (file-newer-than-file-p tmp-name3 tmp-name1)))) | 3763 | (should-not (file-newer-than-file-p tmp-name3 tmp-name1)) |
| 3764 | ;; Check the NOFOLLOW arg. It exists since Emacs 28. For | ||
| 3765 | ;; regular files, there shouldn't be a difference. | ||
| 3766 | (when (tramp--test-emacs28-p) | ||
| 3767 | (with-no-warnings | ||
| 3768 | (set-file-times tmp-name1 (seconds-to-time 1) 'nofollow) | ||
| 3769 | (should | ||
| 3770 | (tramp-compat-time-equal-p | ||
| 3771 | (tramp-compat-file-attribute-modification-time | ||
| 3772 | (file-attributes tmp-name1)) | ||
| 3773 | (seconds-to-time 1))))))) | ||
| 3765 | 3774 | ||
| 3766 | ;; Cleanup. | 3775 | ;; Cleanup. |
| 3767 | (ignore-errors | 3776 | (ignore-errors |