mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-05 22:20:24 -08:00
Add set-file-times implementation for Tramp smb method
* lisp/net/tramp-adb.el (tramp-adb-handle-set-file-times): Don't use UTC in all cases. * lisp/net/tramp-smb.el (tramp-smb-handle-set-file-times): New defun. (tramp-smb-file-name-handler-alist): Use it. * test/lisp/net/tramp-tests.el (tramp-test22-file-times): Adapt test.
This commit is contained in:
parent
d950ca8ccd
commit
d3cd93dc4d
3 changed files with 19 additions and 8 deletions
|
|
@ -573,9 +573,9 @@ Emacs dired can't find files."
|
|||
"touch -t %s %s %s")
|
||||
(format-time-string "%Y-%m-%dT%H:%M:%S.%NZ" time t)
|
||||
nofollow quoted-name (tramp-get-remote-null-device v)
|
||||
(format-time-string "%Y-%m-%dT%H:%M:%S" time t)
|
||||
(format-time-string "%Y-%m-%dT%H:%M:%S" time)
|
||||
nofollow quoted-name (tramp-get-remote-null-device v)
|
||||
(format-time-string "%Y%m%d%H%M.%S" time t)
|
||||
(format-time-string "%Y%m%d%H%M.%S" time)
|
||||
nofollow quoted-name)))))
|
||||
|
||||
(defun tramp-adb-handle-copy-file
|
||||
|
|
|
|||
|
|
@ -295,7 +295,7 @@ See `tramp-actions-before-shell' for more info.")
|
|||
(set-file-acl . tramp-smb-handle-set-file-acl)
|
||||
(set-file-modes . tramp-smb-handle-set-file-modes)
|
||||
(set-file-selinux-context . ignore)
|
||||
(set-file-times . ignore)
|
||||
(set-file-times . tramp-smb-handle-set-file-times)
|
||||
(set-visited-file-modtime . tramp-handle-set-visited-file-modtime)
|
||||
(shell-command . tramp-handle-shell-command)
|
||||
(start-file-process . tramp-smb-handle-start-file-process)
|
||||
|
|
@ -1534,6 +1534,15 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
|
|||
(tramp-error
|
||||
v 'file-error "Error while changing file's mode %s" filename))))))
|
||||
|
||||
(defun tramp-smb-handle-set-file-times (filename &optional time _flag)
|
||||
"Like `set-file-times' for Tramp files."
|
||||
(tramp-skeleton-set-file-modes-times-uid-gid filename
|
||||
(tramp-smb-send-command
|
||||
v (format
|
||||
"utimes %s -1 -1 %s -1"
|
||||
(tramp-smb-shell-quote-localname v)
|
||||
(format-time-string "%Y:%m:%d-%H:%M:%S" (tramp-defined-time time))))))
|
||||
|
||||
;; We use BUFFER also as connection buffer during setup. Because of
|
||||
;; this, its original contents must be saved, and restored once
|
||||
;; connection has been setup.
|
||||
|
|
|
|||
|
|
@ -4552,7 +4552,8 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
|
|||
(skip-unless (tramp--test-enabled))
|
||||
(skip-unless
|
||||
(or (tramp--test-adb-p) (tramp--test-gvfs-p)
|
||||
(tramp--test-sh-p) (tramp--test-sudoedit-p)))
|
||||
(tramp--test-sh-p) (tramp--test-smb-p)
|
||||
(tramp--test-sudoedit-p)))
|
||||
|
||||
(dolist (quoted (if (tramp--test-expensive-test-p) '(nil t) '(nil)))
|
||||
(let ((tmp-name1 (tramp--test-make-temp-name nil quoted))
|
||||
|
|
@ -4565,9 +4566,10 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
|
|||
(should (consp (file-attribute-modification-time
|
||||
(file-attributes tmp-name1))))
|
||||
;; Skip the test, if the remote handler is not able to set
|
||||
;; the correct time.
|
||||
;; Some remote machines cannot resolve seconds. So we use a minute.
|
||||
(skip-unless (set-file-times tmp-name1 (seconds-to-time 60)))
|
||||
;; the correct time. Some remote machines cannot resolve
|
||||
;; seconds. tramp-adb.el needs at least a day.
|
||||
(skip-unless
|
||||
(set-file-times tmp-name1 (seconds-to-time (* 24 60 60))))
|
||||
;; Dumb remote shells without perl(1) or stat(1) are not
|
||||
;; able to return the date correctly. They say "don't know".
|
||||
(unless (time-equal-p
|
||||
|
|
@ -4577,7 +4579,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
|
|||
(should
|
||||
(time-equal-p
|
||||
(file-attribute-modification-time (file-attributes tmp-name1))
|
||||
(seconds-to-time 60)))
|
||||
(seconds-to-time (* 24 60 60))))
|
||||
;; Setting the time for not existing files shall fail.
|
||||
(should-error
|
||||
(set-file-times tmp-name2)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue