From: Michael Albinus Date: Tue, 9 Aug 2022 16:12:27 +0000 (+0200) Subject: Further Tramp fixes for Android 12 X-Git-Tag: emacs-29.0.90~1447^2~281^2~4 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=b0653b27e25bfad2416364c33e1a5994285435c4;p=emacs.git Further Tramp fixes for Android 12 * lisp/net/tramp-adb.el (tramp-adb-handle-file-attributes) (tramp-adb-handle-directory-files-and-attributes) (tramp-adb-handle-file-name-all-completions): Pipe "ls" output through "cat", in order to avoid quoting special characters. (tramp-adb-sh-fix-ls-output): Remove fix for file names with spaces. * test/lisp/net/tramp-tests.el (tramp-test22-file-times): Adapt test. --- diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el index ed51628c4a7..d033667e87f 100644 --- a/lisp/net/tramp-adb.el +++ b/lisp/net/tramp-adb.el @@ -257,7 +257,7 @@ arguments to pass to the OPERATION." (tramp-convert-file-attributes v localname id-format (and (tramp-adb-send-command-and-check - v (format "%s -d -l %s" + v (format "%s -d -l %s | cat" (tramp-adb-get-ls-command v) (tramp-shell-quote-argument localname))) (with-current-buffer (tramp-get-buffer v) @@ -310,16 +310,15 @@ arguments to pass to the OPERATION." directory full match nosort id-format count (with-current-buffer (tramp-get-buffer v) (when (tramp-adb-send-command-and-check - v (format "%s -a -l %s" + v (format "%s -a -l %s | cat" (tramp-adb-get-ls-command v) (tramp-shell-quote-argument localname))) ;; We insert also filename/. and filename/.., because "ls" - ;; doesn't. Looks like it does include them in toybox, since - ;; Android 6. + ;; doesn't on some file systems, like "sdcard". (unless (re-search-backward "\\.$" nil t) (narrow-to-region (point-max) (point-max)) (tramp-adb-send-command - v (format "%s -d -a -l %s %s" + v (format "%s -d -a -l %s %s | cat" (tramp-adb-get-ls-command v) (tramp-shell-quote-argument (tramp-compat-file-name-concat localname ".")) @@ -362,10 +361,6 @@ arguments to pass to the OPERATION." Android's \"ls\" command doesn't insert size column for directories: Emacs dired can't find files." (save-excursion - ;; Fix file names with spaces. - ;; FIXME: It would be better if we could call "ls" with proper - ;; argument or environment variable. - (replace-string-in-region "\\ " " " (point-min)) ;; Insert missing size. (goto-char (point-min)) (while @@ -460,7 +455,7 @@ Emacs dired can't find files." (with-parsed-tramp-file-name (expand-file-name directory) nil (with-tramp-file-property v localname "file-name-all-completions" (tramp-adb-send-command - v (format "%s -a %s" + v (format "%s -a %s | cat" (tramp-adb-get-ls-command v) (tramp-shell-quote-argument localname))) (mapcar @@ -471,9 +466,8 @@ Emacs dired can't find files." (with-current-buffer (tramp-get-buffer v) (delete-dups (append - ;; In older Android versions, "." and ".." are not - ;; included. In newer versions (toybox, since Android 6) - ;; they are. We fix this by `delete-dups'. + ;; On some file systems like "sdcard", "." and ".." are + ;; not included. We fix this by `delete-dups'. '("." "..") (delq nil diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el index a3e80e89562..ad81d0c09ea 100644 --- a/test/lisp/net/tramp-tests.el +++ b/test/lisp/net/tramp-tests.el @@ -4160,7 +4160,8 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." (file-attributes tmp-name1)))) ;; Skip the test, if the remote handler is not able to set ;; the correct time. - (skip-unless (set-file-times tmp-name1 (seconds-to-time 1))) + ;; Some remote machines cannot resolve seconds. So we use a minute. + (skip-unless (set-file-times tmp-name1 (seconds-to-time 60))) ;; Dumb remote shells without perl(1) or stat(1) are not ;; able to return the date correctly. They say "don't know". (unless (tramp-compat-time-equal-p @@ -4168,16 +4169,9 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." (file-attributes tmp-name1)) tramp-time-dont-know) (should - (or (tramp-compat-time-equal-p - (file-attribute-modification-time - (file-attributes tmp-name1)) - (seconds-to-time 1)) - ;; Some remote machines cannot resolve seconds. - ;; The return the modification time `(0 0). - (tramp-compat-time-equal-p - (file-attribute-modification-time - (file-attributes tmp-name1)) - (seconds-to-time 0)))) + (tramp-compat-time-equal-p + (file-attribute-modification-time (file-attributes tmp-name1)) + (seconds-to-time 60))) ;; Setting the time for not existing files shall fail. (should-error (set-file-times tmp-name2) @@ -4192,18 +4186,12 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." ;; regular files, there shouldn't be a difference. (when (tramp--test-emacs28-p) (with-no-warnings - (set-file-times tmp-name1 (seconds-to-time 1) 'nofollow) + (set-file-times tmp-name1 (seconds-to-time 60) 'nofollow) (should - (or (tramp-compat-time-equal-p - (file-attribute-modification-time - (file-attributes tmp-name1)) - (seconds-to-time 1)) - ;; Some remote machines cannot resolve seconds. - ;; The return the modification time `(0 0). - (tramp-compat-time-equal-p - (file-attribute-modification-time - (file-attributes tmp-name1)) - (seconds-to-time 0)))))))) + (tramp-compat-time-equal-p + (file-attribute-modification-time + (file-attributes tmp-name1)) + (seconds-to-time 60))))))) ;; Cleanup. (ignore-errors