But I had to apply the patch at a different spot (line 1580):
;; We handle also the local part, because there doesn't exist
;; `set-file-uid-gid'. On W32 "chown" might not work. We add a
;; timeout for this.
(with-timeout (5 nil)
(let ((uid (or (and (natnump uid) uid) (tramp-get-local-uid 'integer)))
(gid (or (and (natnump gid) gid) (tramp-get-local-gid 'integer))))
nil "chown" nil nil nil
(format "%d:%d" uid gid) (shell-quote-argument filename)))))))
;; (format "%d:%d" uid gid) (tramp-shell-quote-argument filename)))))))
The problem is still the same though (even with the correct quote), the chown process takes 48 seconds to fail.
The "with-timeout" does not help, because:
Since timers can run within a Lisp program only when the program
calls a primitive that can wait, ‘with-timeout’ cannot stop
executing BODY while it is in the midst of a computation—only when
it calls one of those primitives. So use ‘with-timeout’ only with
a BODY that waits for input, not one that does a long computation.
Could we turn off the call to chown on a W32 system?