1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-15 10:30:25 -08:00

Some Tramp fixes for directory-files-* and delete-*

* lisp/files.el (delete-directory): Simplify check for trash.

* lisp/net/ange-ftp.el (ange-ftp-delete-file): Implement TRASH.

* lisp/net/tramp-compat.el (tramp-compat-directory-files)
(tramp-compat-directory-files-and-attributes)
(tramp-compat-directory-empty-p): New defaliases.

* lisp/net/tramp.el (tramp-handle-directory-files-and-attributes)
(tramp-skeleton-delete-directory):
* lisp/net/tramp-gvfs.el (tramp-gvfs-handle-delete-directory): Use them.

* lisp/net/tramp-sh.el (tramp-sh-handle-directory-files-and-attributes):
Implement COUNT.

* test/lisp/net/tramp-tests.el (tramp-test14-delete-directory):
Do not run trash test for ange-ftp.
(tramp-test16-directory-files)
(tramp-test19-directory-files-and-attributes): Check COUNT argument.
This commit is contained in:
Michael Albinus 2020-11-03 18:47:32 +01:00
parent f9d6e463d3
commit 2fffc1dfdf
7 changed files with 118 additions and 66 deletions

View file

@ -2783,8 +2783,9 @@ This tests also `file-directory-p' and `file-accessible-directory-p'."
(should-not (file-directory-p tmp-name1))
;; Trashing directories works only since Emacs 27.1. It doesn't
;; work for crypted remote directories.
(when (and (not (tramp--test-crypt-p)) (tramp--test-emacs27-p))
;; work for crypted remote directories and for ange-ftp.
(when (and (not (tramp--test-crypt-p)) (not (tramp--test-ftp-p))
(tramp--test-emacs27-p))
(let ((trash-directory (tramp--test-make-temp-name 'local quoted))
(delete-by-moving-to-trash t))
(make-directory trash-directory)
@ -2925,7 +2926,15 @@ This tests also `file-directory-p' and `file-accessible-directory-p'."
'("bla" "foo")))
(should (equal (directory-files
tmp-name1 'full directory-files-no-dot-files-regexp)
`(,tmp-name2 ,tmp-name3))))
`(,tmp-name2 ,tmp-name3)))
;; Check the COUNT arg. It exists since Emacs 28.
(when (tramp--test-emacs28-p)
(with-no-warnings
(should
(= 1 (length
(directory-files
tmp-name1 nil directory-files-no-dot-files-regexp
nil 1)))))))
;; Cleanup.
(ignore-errors (delete-directory tmp-name1 'recursive))))))
@ -3443,7 +3452,13 @@ They might differ only in time attributes or directory size."
(file-attributes (car elt)) (cdr elt))))
(setq attr (directory-files-and-attributes tmp-name2 nil "\\`b"))
(should (equal (mapcar #'car attr) '("bar" "boz"))))
(should (equal (mapcar #'car attr) '("bar" "boz")))
;; Check the COUNT arg. It exists since Emacs 28.
(when (tramp--test-emacs28-p)
(with-no-warnings
(should (= 1 (length (directory-files-and-attributes
tmp-name2 nil "\\`b" nil nil 1)))))))
;; Cleanup.
(ignore-errors (delete-directory tmp-name1 'recursive))))))