aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/net/tramp-adb.el12
-rw-r--r--lisp/net/tramp-gvfs.el4
-rw-r--r--lisp/net/tramp-rclone.el8
-rw-r--r--lisp/net/tramp-sh.el11
-rw-r--r--lisp/net/tramp-smb.el19
-rw-r--r--lisp/net/tramp-sudoedit.el4
-rw-r--r--lisp/net/tramp.el15
-rw-r--r--test/lisp/net/tramp-tests.el44
8 files changed, 102 insertions, 15 deletions
diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el
index e1706bebe6e..e3098190e2b 100644
--- a/lisp/net/tramp-adb.el
+++ b/lisp/net/tramp-adb.el
@@ -383,6 +383,10 @@ ARGUMENTS to pass to the OPERATION."
383(defun tramp-adb-handle-directory-files-and-attributes 383(defun tramp-adb-handle-directory-files-and-attributes
384 (directory &optional full match nosort id-format) 384 (directory &optional full match nosort id-format)
385 "Like `directory-files-and-attributes' for Tramp files." 385 "Like `directory-files-and-attributes' for Tramp files."
386 (unless (file-exists-p directory)
387 (tramp-error
388 (tramp-dissect-file-name directory) tramp-file-missing
389 "No such file or directory" directory))
386 (when (file-directory-p directory) 390 (when (file-directory-p directory)
387 (with-parsed-tramp-file-name (expand-file-name directory) nil 391 (with-parsed-tramp-file-name (expand-file-name directory) nil
388 (copy-tree 392 (copy-tree
@@ -706,6 +710,10 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
706 (let ((t1 (tramp-tramp-file-p filename)) 710 (let ((t1 (tramp-tramp-file-p filename))
707 (t2 (tramp-tramp-file-p newname))) 711 (t2 (tramp-tramp-file-p newname)))
708 (with-parsed-tramp-file-name (if t1 filename newname) nil 712 (with-parsed-tramp-file-name (if t1 filename newname) nil
713 (unless (file-exists-p filename)
714 (tramp-error
715 v tramp-file-missing
716 "Copying file" "No such file or directory" filename))
709 (when (and (not ok-if-already-exists) (file-exists-p newname)) 717 (when (and (not ok-if-already-exists) (file-exists-p newname))
710 (tramp-error v 'file-already-exists newname)) 718 (tramp-error v 'file-already-exists newname))
711 (when (and (file-directory-p newname) 719 (when (and (file-directory-p newname)
@@ -784,6 +792,10 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
784 (let ((t1 (tramp-tramp-file-p filename)) 792 (let ((t1 (tramp-tramp-file-p filename))
785 (t2 (tramp-tramp-file-p newname))) 793 (t2 (tramp-tramp-file-p newname)))
786 (with-parsed-tramp-file-name (if t1 filename newname) nil 794 (with-parsed-tramp-file-name (if t1 filename newname) nil
795 (unless (file-exists-p filename)
796 (tramp-error
797 v tramp-file-missing
798 "Renaming file" "No such file or directory" filename))
787 (when (and (not ok-if-already-exists) (file-exists-p newname)) 799 (when (and (not ok-if-already-exists) (file-exists-p newname))
788 (tramp-error v 'file-already-exists newname)) 800 (tramp-error v 'file-already-exists newname))
789 (when (and (file-directory-p newname) 801 (when (and (file-directory-p newname)
diff --git a/lisp/net/tramp-gvfs.el b/lisp/net/tramp-gvfs.el
index c08c7194cc7..6f5cade4c63 100644
--- a/lisp/net/tramp-gvfs.el
+++ b/lisp/net/tramp-gvfs.el
@@ -765,6 +765,10 @@ file names."
765 (msg-operation (if (eq op 'copy) "Copying" "Renaming"))) 765 (msg-operation (if (eq op 'copy) "Copying" "Renaming")))
766 766
767 (with-parsed-tramp-file-name (if t1 filename newname) nil 767 (with-parsed-tramp-file-name (if t1 filename newname) nil
768 (unless (file-exists-p filename)
769 (tramp-error
770 v tramp-file-missing
771 "%s file" msg-operation "No such file or directory" filename))
768 (when (and (not ok-if-already-exists) (file-exists-p newname)) 772 (when (and (not ok-if-already-exists) (file-exists-p newname))
769 (tramp-error v 'file-already-exists newname)) 773 (tramp-error v 'file-already-exists newname))
770 (when (and (file-directory-p newname) 774 (when (and (file-directory-p newname)
diff --git a/lisp/net/tramp-rclone.el b/lisp/net/tramp-rclone.el
index 1f0c7eadbc5..2b3799ef008 100644
--- a/lisp/net/tramp-rclone.el
+++ b/lisp/net/tramp-rclone.el
@@ -213,6 +213,10 @@ file names."
213 (msg-operation (if (eq op 'copy) "Copying" "Renaming"))) 213 (msg-operation (if (eq op 'copy) "Copying" "Renaming")))
214 214
215 (with-parsed-tramp-file-name (if t1 filename newname) nil 215 (with-parsed-tramp-file-name (if t1 filename newname) nil
216 (unless (file-exists-p filename)
217 (tramp-error
218 v tramp-file-missing
219 "%s file" msg-operation "No such file or directory" filename))
216 (when (and (not ok-if-already-exists) (file-exists-p newname)) 220 (when (and (not ok-if-already-exists) (file-exists-p newname))
217 (tramp-error v 'file-already-exists newname)) 221 (tramp-error v 'file-already-exists newname))
218 (when (and (file-directory-p newname) 222 (when (and (file-directory-p newname)
@@ -298,6 +302,10 @@ file names."
298(defun tramp-rclone-handle-directory-files 302(defun tramp-rclone-handle-directory-files
299 (directory &optional full match nosort) 303 (directory &optional full match nosort)
300 "Like `directory-files' for Tramp files." 304 "Like `directory-files' for Tramp files."
305 (unless (file-exists-p directory)
306 (tramp-error
307 (tramp-dissect-file-name directory) tramp-file-missing
308 "No such file or directory" directory))
301 (when (file-directory-p directory) 309 (when (file-directory-p directory)
302 (setq directory (file-name-as-directory (expand-file-name directory))) 310 (setq directory (file-name-as-directory (expand-file-name directory)))
303 (with-parsed-tramp-file-name directory nil 311 (with-parsed-tramp-file-name directory nil
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index 3c80c583099..be531ed3192 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -1713,6 +1713,10 @@ of."
1713 (directory &optional full match nosort id-format) 1713 (directory &optional full match nosort id-format)
1714 "Like `directory-files-and-attributes' for Tramp files." 1714 "Like `directory-files-and-attributes' for Tramp files."
1715 (unless id-format (setq id-format 'integer)) 1715 (unless id-format (setq id-format 'integer))
1716 (unless (file-exists-p directory)
1717 (tramp-error
1718 (tramp-dissect-file-name directory) tramp-file-missing
1719 "No such file or directory" directory))
1716 (when (file-directory-p directory) 1720 (when (file-directory-p directory)
1717 (setq directory (expand-file-name directory)) 1721 (setq directory (expand-file-name directory))
1718 (let* ((temp 1722 (let* ((temp
@@ -1923,6 +1927,10 @@ tramp-sh-handle-file-name-all-completions: internal error accessing `%s': `%s'"
1923 (let ((t1 (tramp-tramp-file-p dirname)) 1927 (let ((t1 (tramp-tramp-file-p dirname))
1924 (t2 (tramp-tramp-file-p newname))) 1928 (t2 (tramp-tramp-file-p newname)))
1925 (with-parsed-tramp-file-name (if t1 dirname newname) nil 1929 (with-parsed-tramp-file-name (if t1 dirname newname) nil
1930 (unless (file-exists-p dirname)
1931 (tramp-error
1932 v tramp-file-missing
1933 "Copying directory" "No such file or directory" dirname))
1926 (if (and (not copy-contents) 1934 (if (and (not copy-contents)
1927 (tramp-get-method-parameter v 'tramp-copy-recursive) 1935 (tramp-get-method-parameter v 'tramp-copy-recursive)
1928 ;; When DIRNAME and NEWNAME are remote, they must have 1936 ;; When DIRNAME and NEWNAME are remote, they must have
@@ -2011,6 +2019,9 @@ file names."
2011 (apply #'file-extended-attributes (list filename))))) 2019 (apply #'file-extended-attributes (list filename)))))
2012 2020
2013 (with-parsed-tramp-file-name (if t1 filename newname) nil 2021 (with-parsed-tramp-file-name (if t1 filename newname) nil
2022 (unless (file-exists-p filename)
2023 (tramp-error
2024 v tramp-file-missing "No such file or directory" filename))
2014 (when (and (not ok-if-already-exists) (file-exists-p newname)) 2025 (when (and (not ok-if-already-exists) (file-exists-p newname))
2015 (tramp-error v 'file-already-exists newname)) 2026 (tramp-error v 'file-already-exists newname))
2016 (when (and (file-directory-p newname) 2027 (when (and (file-directory-p newname)
diff --git a/lisp/net/tramp-smb.el b/lisp/net/tramp-smb.el
index 5e52b26e7c6..f87d4becfe0 100644
--- a/lisp/net/tramp-smb.el
+++ b/lisp/net/tramp-smb.el
@@ -415,6 +415,10 @@ pass to the OPERATION."
415 (with-parsed-tramp-file-name (if t1 dirname newname) nil 415 (with-parsed-tramp-file-name (if t1 dirname newname) nil
416 (with-tramp-progress-reporter 416 (with-tramp-progress-reporter
417 v 0 (format "Copying %s to %s" dirname newname) 417 v 0 (format "Copying %s to %s" dirname newname)
418 (unless (file-exists-p dirname)
419 (tramp-error
420 v tramp-file-missing
421 "Copying directory" "No such file or directory" dirname))
418 (when (and (file-directory-p newname) 422 (when (and (file-directory-p newname)
419 (not (tramp-compat-directory-name-p newname))) 423 (not (tramp-compat-directory-name-p newname)))
420 (tramp-error v 'file-already-exists newname)) 424 (tramp-error v 'file-already-exists newname))
@@ -570,6 +574,13 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
570 (if (file-directory-p filename) 574 (if (file-directory-p filename)
571 (copy-directory filename newname keep-date 'parents 'copy-contents) 575 (copy-directory filename newname keep-date 'parents 'copy-contents)
572 576
577 (unless (file-exists-p filename)
578 (tramp-error
579 (tramp-dissect-file-name
580 (if (tramp-tramp-file-p filename) filename newname))
581 tramp-file-missing
582 "Copying file" "No such file or directory" filename))
583
573 (let ((tmpfile (file-local-copy filename))) 584 (let ((tmpfile (file-local-copy filename)))
574 (if tmpfile 585 (if tmpfile
575 ;; Remote filename. 586 ;; Remote filename.
@@ -669,6 +680,10 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
669(defun tramp-smb-handle-directory-files 680(defun tramp-smb-handle-directory-files
670 (directory &optional full match nosort) 681 (directory &optional full match nosort)
671 "Like `directory-files' for Tramp files." 682 "Like `directory-files' for Tramp files."
683 (unless (file-exists-p directory)
684 (tramp-error
685 (tramp-dissect-file-name directory) tramp-file-missing
686 "No such file or directory" directory))
672 (let ((result (mapcar #'directory-file-name 687 (let ((result (mapcar #'directory-file-name
673 (file-name-all-completions "" directory)))) 688 (file-name-all-completions "" directory))))
674 ;; Discriminate with regexp. 689 ;; Discriminate with regexp.
@@ -1333,6 +1348,10 @@ component is used as the target of the symlink."
1333 1348
1334 (with-parsed-tramp-file-name 1349 (with-parsed-tramp-file-name
1335 (if (tramp-tramp-file-p filename) filename newname) nil 1350 (if (tramp-tramp-file-p filename) filename newname) nil
1351 (unless (file-exists-p filename)
1352 (tramp-error
1353 v tramp-file-missing
1354 "Renaming file" "No such file or directory" filename))
1336 (when (and (not ok-if-already-exists) (file-exists-p newname)) 1355 (when (and (not ok-if-already-exists) (file-exists-p newname))
1337 (tramp-error v 'file-already-exists newname)) 1356 (tramp-error v 'file-already-exists newname))
1338 (when (and (file-directory-p newname) 1357 (when (and (file-directory-p newname)
diff --git a/lisp/net/tramp-sudoedit.el b/lisp/net/tramp-sudoedit.el
index bfc9b3bdc3a..2d9d7ff7892 100644
--- a/lisp/net/tramp-sudoedit.el
+++ b/lisp/net/tramp-sudoedit.el
@@ -241,6 +241,10 @@ absolute file names."
241 (msg-operation (if (eq op 'copy) "Copying" "Renaming"))) 241 (msg-operation (if (eq op 'copy) "Copying" "Renaming")))
242 242
243 (with-parsed-tramp-file-name (if t1 filename newname) nil 243 (with-parsed-tramp-file-name (if t1 filename newname) nil
244 (unless (file-exists-p filename)
245 (tramp-error
246 v tramp-file-missing
247 "%s file" msg-operation "No such file or directory" filename))
244 (when (and (not ok-if-already-exists) (file-exists-p newname)) 248 (when (and (not ok-if-already-exists) (file-exists-p newname))
245 (tramp-error v 'file-already-exists newname)) 249 (tramp-error v 'file-already-exists newname))
246 (when (and (file-directory-p newname) 250 (when (and (file-directory-p newname)
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index 21b6f0070f7..88ff36d98ea 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -719,7 +719,7 @@ Used in user option `tramp-syntax'. There are further variables
719to be set, depending on VALUE." 719to be set, depending on VALUE."
720 ;; Check allowed values. 720 ;; Check allowed values.
721 (unless (memq value (tramp-syntax-values)) 721 (unless (memq value (tramp-syntax-values))
722 (tramp-user-error "Wrong `tramp-syntax' %s" value)) 722 (tramp-user-error nil "Wrong `tramp-syntax' %s" value))
723 ;; Cleanup existing buffers. 723 ;; Cleanup existing buffers.
724 (unless (eq (symbol-value symbol) value) 724 (unless (eq (symbol-value symbol) value)
725 (tramp-cleanup-all-buffers)) 725 (tramp-cleanup-all-buffers))
@@ -1889,8 +1889,13 @@ the resulting error message."
1889;; This function provides traces in case of errors not triggered by 1889;; This function provides traces in case of errors not triggered by
1890;; Tramp functions. 1890;; Tramp functions.
1891(defun tramp-signal-hook-function (error-symbol data) 1891(defun tramp-signal-hook-function (error-symbol data)
1892 "Funtion to be called via `signal-hook-function'." 1892 "Function to be called via `signal-hook-function'."
1893 (tramp-error (car tramp-current-connection) error-symbol "%s" data)) 1893 ;; `custom-initialize-*' functions provoke `void-variable' errors.
1894 ;; We don't want to see them in the backtrace.
1895 (unless (eq error-symbol 'void-variable)
1896 (tramp-error
1897 (car tramp-current-connection) error-symbol
1898 "%s" (mapconcat (lambda (x) (format "%s" x)) data " "))))
1894 1899
1895(defmacro with-parsed-tramp-file-name (filename var &rest body) 1900(defmacro with-parsed-tramp-file-name (filename var &rest body)
1896 "Parse a Tramp filename and make components available in the body. 1901 "Parse a Tramp filename and make components available in the body.
@@ -3025,6 +3030,10 @@ User is always nil."
3025 3030
3026(defun tramp-handle-directory-files (directory &optional full match nosort) 3031(defun tramp-handle-directory-files (directory &optional full match nosort)
3027 "Like `directory-files' for Tramp files." 3032 "Like `directory-files' for Tramp files."
3033 (unless (file-exists-p directory)
3034 (tramp-error
3035 (tramp-dissect-file-name directory) tramp-file-missing
3036 "No such file or directory" directory))
3028 (when (file-directory-p directory) 3037 (when (file-directory-p directory)
3029 (setq directory (file-name-as-directory (expand-file-name directory))) 3038 (setq directory (file-name-as-directory (expand-file-name directory)))
3030 (let ((temp (nreverse (file-name-all-completions "" directory))) 3039 (let ((temp (nreverse (file-name-all-completions "" directory)))
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el
index baebae17e1f..ec9cda0bbdd 100644
--- a/test/lisp/net/tramp-tests.el
+++ b/test/lisp/net/tramp-tests.el
@@ -2370,6 +2370,9 @@ This checks also `file-name-as-directory', `file-name-directory',
2370 ;; Copy simple file. 2370 ;; Copy simple file.
2371 (unwind-protect 2371 (unwind-protect
2372 (progn 2372 (progn
2373 (should-error
2374 (copy-file source target)
2375 :type tramp-file-missing)
2373 (write-region "foo" nil source) 2376 (write-region "foo" nil source)
2374 (should (file-exists-p source)) 2377 (should (file-exists-p source))
2375 (copy-file source target) 2378 (copy-file source target)
@@ -2482,6 +2485,9 @@ This checks also `file-name-as-directory', `file-name-directory',
2482 ;; Rename simple file. 2485 ;; Rename simple file.
2483 (unwind-protect 2486 (unwind-protect
2484 (progn 2487 (progn
2488 (should-error
2489 (rename-file source target)
2490 :type tramp-file-missing)
2485 (write-region "foo" nil source) 2491 (write-region "foo" nil source)
2486 (should (file-exists-p source)) 2492 (should (file-exists-p source))
2487 (rename-file source target) 2493 (rename-file source target)
@@ -2605,20 +2611,25 @@ This tests also `file-directory-p' and `file-accessible-directory-p'."
2605 (skip-unless (tramp--test-enabled)) 2611 (skip-unless (tramp--test-enabled))
2606 2612
2607 (dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil))) 2613 (dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil)))
2608 (let ((tmp-name (tramp--test-make-temp-name nil quoted))) 2614 (let* ((tmp-name1 (tramp--test-make-temp-name nil quoted))
2615 (tmp-name2 (expand-file-name "foo" tmp-name1)))
2609 ;; Delete empty directory. 2616 ;; Delete empty directory.
2610 (make-directory tmp-name) 2617 (make-directory tmp-name1)
2611 (should (file-directory-p tmp-name)) 2618 (should (file-directory-p tmp-name1))
2612 (delete-directory tmp-name) 2619 (delete-directory tmp-name1)
2613 (should-not (file-directory-p tmp-name)) 2620 (should-not (file-directory-p tmp-name1))
2614 ;; Delete non-empty directory. 2621 ;; Delete non-empty directory.
2615 (make-directory tmp-name) 2622 (make-directory tmp-name1)
2616 (should (file-directory-p tmp-name)) 2623 (should (file-directory-p tmp-name1))
2617 (write-region "foo" nil (expand-file-name "bla" tmp-name)) 2624 (write-region "foo" nil (expand-file-name "bla" tmp-name1))
2618 (should (file-exists-p (expand-file-name "bla" tmp-name))) 2625 (should (file-exists-p (expand-file-name "bla" tmp-name1)))
2619 (should-error (delete-directory tmp-name) :type 'file-error) 2626 (make-directory tmp-name2)
2620 (delete-directory tmp-name 'recursive) 2627 (should (file-directory-p tmp-name2))
2621 (should-not (file-directory-p tmp-name))))) 2628 (write-region "foo" nil (expand-file-name "bla" tmp-name2))
2629 (should (file-exists-p (expand-file-name "bla" tmp-name2)))
2630 (should-error (delete-directory tmp-name1) :type 'file-error)
2631 (delete-directory tmp-name1 'recursive)
2632 (should-not (file-directory-p tmp-name1)))))
2622 2633
2623(ert-deftest tramp-test15-copy-directory () 2634(ert-deftest tramp-test15-copy-directory ()
2624 "Check `copy-directory'." 2635 "Check `copy-directory'."
@@ -2636,6 +2647,9 @@ This tests also `file-directory-p' and `file-accessible-directory-p'."
2636 ;; Copy complete directory. 2647 ;; Copy complete directory.
2637 (unwind-protect 2648 (unwind-protect
2638 (progn 2649 (progn
2650 (should-error
2651 (copy-directory tmp-name1 tmp-name2)
2652 :type tramp-file-missing)
2639 ;; Copy empty directory. 2653 ;; Copy empty directory.
2640 (make-directory tmp-name1) 2654 (make-directory tmp-name1)
2641 (write-region "foo" nil tmp-name4) 2655 (write-region "foo" nil tmp-name4)
@@ -2696,6 +2710,9 @@ This tests also `file-directory-p' and `file-accessible-directory-p'."
2696 (tmp-name3 (expand-file-name "foo" tmp-name1))) 2710 (tmp-name3 (expand-file-name "foo" tmp-name1)))
2697 (unwind-protect 2711 (unwind-protect
2698 (progn 2712 (progn
2713 (should-error
2714 (directory-files tmp-name1)
2715 :type tramp-file-missing)
2699 (make-directory tmp-name1) 2716 (make-directory tmp-name1)
2700 (write-region "foo" nil tmp-name2) 2717 (write-region "foo" nil tmp-name2)
2701 (write-region "bla" nil tmp-name3) 2718 (write-region "bla" nil tmp-name3)
@@ -3174,6 +3191,9 @@ They might differ only in time attributes or directory size."
3174 attr) 3191 attr)
3175 (unwind-protect 3192 (unwind-protect
3176 (progn 3193 (progn
3194 (should-error
3195 (directory-files-and-attributes tmp-name1)
3196 :type tramp-file-missing)
3177 (make-directory tmp-name1) 3197 (make-directory tmp-name1)
3178 (should (file-directory-p tmp-name1)) 3198 (should (file-directory-p tmp-name1))
3179 (setq tramp--test-start-time 3199 (setq tramp--test-start-time