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.
2 jobs for master in 67 minutes and 20 seconds (queued for 1 second)
Status Job ID Name Coverage
  Test
failed #5299
test-all

01:07:20

passed #5300
test-filenotify-gio

00:43:15

 
Name Stage Failure
failed
test-all Test
Makefile:319: recipe for target 'check-doit' failed
make[2]: *** [check-doit] Error 1
make[2]: Leaving directory '/builds/emacs/emacs/test'
Makefile:294: recipe for target 'check-expensive' failed
make[1]: *** [check-expensive] Error 2
make[1]: Leaving directory '/builds/emacs/emacs/test'
Makefile:959: recipe for target 'check-expensive' failed
make: *** [check-expensive] Error 2
ERROR: Job failed: exit code 1