emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 8158337: Fix Bug#40156 in Tramp


From: Michael Albinus
Subject: master 8158337: Fix Bug#40156 in Tramp
Date: Sat, 21 Mar 2020 05:30:37 -0400 (EDT)

branch: master
commit 8158337cc254403fbae6fed3d80064400f62f48b
Author: Michael Albinus <address@hidden>
Commit: Michael Albinus <address@hidden>

    Fix Bug#40156 in Tramp
    
    * lisp/net/tramp-sh.el (tramp-sh-handle-write-region): Copy to temp file
    only if FILENAME exists.  (Bug#40156)
    
    * test/lisp/net/tramp-tests.el (tramp-test10-write-region): Extend test.
---
 lisp/net/tramp-sh.el         | 3 ++-
 test/lisp/net/tramp-tests.el | 9 ++++++++-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index 7ac41d1..06dca31 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -3306,7 +3306,8 @@ STDERR can also be a file name."
 
          ;; If `append' is non-nil, we copy the file locally, and let
          ;; the native `write-region' implementation do the job.
-         (when append (copy-file filename tmpfile 'ok))
+         (when (and append (file-exists-p filename))
+           (copy-file filename tmpfile 'ok))
 
          ;; We say `no-message' here because we don't want the
          ;; visited file modtime data to be clobbered from the temp
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el
index e220420..e6c6b28 100644
--- a/test/lisp/net/tramp-tests.el
+++ b/test/lisp/net/tramp-tests.el
@@ -2356,7 +2356,14 @@ This checks also `file-name-as-directory', 
`file-name-directory',
                (write-region nil nil tmp-name 3))
              (with-temp-buffer
                (insert-file-contents tmp-name)
-               (should (string-equal (buffer-string) "foobaz"))))
+               (should (string-equal (buffer-string) "foobaz")))
+             (delete-file tmp-name)
+             (with-temp-buffer
+               (insert "foo")
+               (write-region nil nil tmp-name 'append))
+             (with-temp-buffer
+               (insert-file-contents tmp-name)
+               (should (string-equal (buffer-string) "foo"))))
 
            ;; Write string.
            (write-region "foo" nil tmp-name)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]