this needs to be _below_ the call to ToPath

This commit is contained in:
Megan Marsh 2018-10-19 14:24:56 -07:00
parent 18c5e8deb8
commit 7d40aeaa33
1 changed files with 3 additions and 2 deletions

View File

@ -563,14 +563,15 @@ func (c *comm) scpUploadSession(path string, input io.Reader, fi *os.FileInfo) e
// The target directory and file for talking the SCP protocol // The target directory and file for talking the SCP protocol
target_dir := filepath.Dir(path) target_dir := filepath.Dir(path)
target_file := filepath.Base(path) target_file := filepath.Base(path)
// Escape spaces in remote directory
target_dir = strings.Replace(target_dir, " ", "\\ ", -1)
// On windows, filepath.Dir uses backslash separators (ie. "\tmp"). // On windows, filepath.Dir uses backslash separators (ie. "\tmp").
// This does not work when the target host is unix. Switch to forward slash // This does not work when the target host is unix. Switch to forward slash
// which works for unix and windows // which works for unix and windows
target_dir = filepath.ToSlash(target_dir) target_dir = filepath.ToSlash(target_dir)
// Escape spaces in remote directory
target_dir = strings.Replace(target_dir, " ", "\\ ", -1)
scpFunc := func(w io.Writer, stdoutR *bufio.Reader) error { scpFunc := func(w io.Writer, stdoutR *bufio.Reader) error {
return scpUploadFile(target_file, input, w, stdoutR, fi) return scpUploadFile(target_file, input, w, stdoutR, fi)
} }