aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2018-08-29 10:05:34 +0200
committerMichael Albinus2018-08-29 10:05:34 +0200
commitc252cd9d207ab8442f011630005e467ad118bd3a (patch)
tree5e1989fc2cff344ab7234cd4121cc68381117b9c
parent190e85b8d286408a88bb611967e658639c48d6c5 (diff)
downloademacs-c252cd9d207ab8442f011630005e467ad118bd3a.tar.gz
emacs-c252cd9d207ab8442f011630005e467ad118bd3a.zip
Improve tramp-convert-file-attributes backward compatibility
* lisp/net/tramp-sh.el (tramp-convert-file-attributes): Use `seconds-to-time' for {access, modification, status change} time. Simplify check for inode. * test/lisp/net/tramp-tests.el (tramp-test22-file-times): Use `seconds-to-time'.
-rw-r--r--lisp/net/tramp-sh.el16
-rw-r--r--test/lisp/net/tramp-tests.el5
2 files changed, 8 insertions, 13 deletions
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index 8cf7318adaa..64d208175f9 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -5116,19 +5116,13 @@ Return ATTR."
5116 (setcar (nthcdr 3 attr) (round (nth 3 attr)))) 5116 (setcar (nthcdr 3 attr) (round (nth 3 attr))))
5117 ;; Convert last access time. 5117 ;; Convert last access time.
5118 (unless (listp (nth 4 attr)) 5118 (unless (listp (nth 4 attr))
5119 (setcar (nthcdr 4 attr) 5119 (setcar (nthcdr 4 attr) (seconds-to-time (nth 4 attr))))
5120 (list (floor (nth 4 attr) 65536)
5121 (floor (mod (nth 4 attr) 65536)))))
5122 ;; Convert last modification time. 5120 ;; Convert last modification time.
5123 (unless (listp (nth 5 attr)) 5121 (unless (listp (nth 5 attr))
5124 (setcar (nthcdr 5 attr) 5122 (setcar (nthcdr 5 attr) (seconds-to-time (nth 5 attr))))
5125 (list (floor (nth 5 attr) 65536)
5126 (floor (mod (nth 5 attr) 65536)))))
5127 ;; Convert last status change time. 5123 ;; Convert last status change time.
5128 (unless (listp (nth 6 attr)) 5124 (unless (listp (nth 6 attr))
5129 (setcar (nthcdr 6 attr) 5125 (setcar (nthcdr 6 attr) (seconds-to-time (nth 6 attr))))
5130 (list (floor (nth 6 attr) 65536)
5131 (floor (mod (nth 6 attr) 65536)))))
5132 ;; Convert file size. 5126 ;; Convert file size.
5133 (when (< (nth 7 attr) 0) 5127 (when (< (nth 7 attr) 0)
5134 (setcar (nthcdr 7 attr) -1)) 5128 (setcar (nthcdr 7 attr) -1))
@@ -5158,8 +5152,8 @@ Return ATTR."
5158 (not (string-equal 5152 (not (string-equal
5159 (nth 3 attr) 5153 (nth 3 attr)
5160 (tramp-get-remote-gid vec 'string))))) 5154 (tramp-get-remote-gid vec 'string)))))
5161 ;; Convert inode. Big numbers have been added to Emacs 27. 5155 ;; Convert inode.
5162 (unless (or (fboundp 'bignump) (listp (nth 10 attr))) 5156 (when (floatp (nth 10 attr))
5163 (setcar (nthcdr 10 attr) 5157 (setcar (nthcdr 10 attr)
5164 (condition-case nil 5158 (condition-case nil
5165 (let ((high (nth 10 attr)) 5159 (let ((high (nth 10 attr))
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el
index 293a0054560..55884f30a7e 100644
--- a/test/lisp/net/tramp-tests.el
+++ b/test/lisp/net/tramp-tests.el
@@ -3219,11 +3219,12 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
3219 ;; `current-time'. Therefore, we use '(0 1). We skip the 3219 ;; `current-time'. Therefore, we use '(0 1). We skip the
3220 ;; test, if the remote handler is not able to set the 3220 ;; test, if the remote handler is not able to set the
3221 ;; correct time. 3221 ;; correct time.
3222 (skip-unless (set-file-times tmp-name1 '(0 1))) 3222 (skip-unless (set-file-times tmp-name1 (seconds-to-time 1)))
3223 ;; Dumb remote shells without perl(1) or stat(1) are not 3223 ;; Dumb remote shells without perl(1) or stat(1) are not
3224 ;; able to return the date correctly. They say "don't know". 3224 ;; able to return the date correctly. They say "don't know".
3225 (unless (equal (nth 5 (file-attributes tmp-name1)) '(0 0)) 3225 (unless (equal (nth 5 (file-attributes tmp-name1)) '(0 0))
3226 (should (equal (nth 5 (file-attributes tmp-name1)) '(0 1))) 3226 (should
3227 (equal (nth 5 (file-attributes tmp-name1)) (seconds-to-time 1)))
3227 (write-region "bla" nil tmp-name2) 3228 (write-region "bla" nil tmp-name2)
3228 (should (file-exists-p tmp-name2)) 3229 (should (file-exists-p tmp-name2))
3229 (should (file-newer-than-file-p tmp-name2 tmp-name1)) 3230 (should (file-newer-than-file-p tmp-name2 tmp-name1))