From: Michael Albinus Date: Wed, 29 Aug 2018 08:05:34 +0000 (+0200) Subject: Improve tramp-convert-file-attributes backward compatibility X-Git-Tag: emacs-27.0.90~4490 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=c252cd9d207ab8442f011630005e467ad118bd3a;p=emacs.git 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'. --- 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." (setcar (nthcdr 3 attr) (round (nth 3 attr)))) ;; Convert last access time. (unless (listp (nth 4 attr)) - (setcar (nthcdr 4 attr) - (list (floor (nth 4 attr) 65536) - (floor (mod (nth 4 attr) 65536))))) + (setcar (nthcdr 4 attr) (seconds-to-time (nth 4 attr)))) ;; Convert last modification time. (unless (listp (nth 5 attr)) - (setcar (nthcdr 5 attr) - (list (floor (nth 5 attr) 65536) - (floor (mod (nth 5 attr) 65536))))) + (setcar (nthcdr 5 attr) (seconds-to-time (nth 5 attr)))) ;; Convert last status change time. (unless (listp (nth 6 attr)) - (setcar (nthcdr 6 attr) - (list (floor (nth 6 attr) 65536) - (floor (mod (nth 6 attr) 65536))))) + (setcar (nthcdr 6 attr) (seconds-to-time (nth 6 attr)))) ;; Convert file size. (when (< (nth 7 attr) 0) (setcar (nthcdr 7 attr) -1)) @@ -5158,8 +5152,8 @@ Return ATTR." (not (string-equal (nth 3 attr) (tramp-get-remote-gid vec 'string))))) - ;; Convert inode. Big numbers have been added to Emacs 27. - (unless (or (fboundp 'bignump) (listp (nth 10 attr))) + ;; Convert inode. + (when (floatp (nth 10 attr)) (setcar (nthcdr 10 attr) (condition-case nil (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'." ;; `current-time'. Therefore, we use '(0 1). We skip the ;; test, if the remote handler is not able to set the ;; correct time. - (skip-unless (set-file-times tmp-name1 '(0 1))) + (skip-unless (set-file-times tmp-name1 (seconds-to-time 1))) ;; Dumb remote shells without perl(1) or stat(1) are not ;; able to return the date correctly. They say "don't know". (unless (equal (nth 5 (file-attributes tmp-name1)) '(0 0)) - (should (equal (nth 5 (file-attributes tmp-name1)) '(0 1))) + (should + (equal (nth 5 (file-attributes tmp-name1)) (seconds-to-time 1))) (write-region "bla" nil tmp-name2) (should (file-exists-p tmp-name2)) (should (file-newer-than-file-p tmp-name2 tmp-name1))