Closed yamamoto-febc closed 7 years ago
This PR will fix to path separator problems when used on Windows.
If you run like following on Windows, it will create a file \remote\path on remote. But what you need is a directory /remote/path.
\remote\path
/remote/path
scpClient := scp.NewSCP(conn) scpClient.SendDir("local", "/remote/path", nil) // file `\remote\path` will be created(not a directory)
The cause is using filepath.Clean as following:
filepath.Clean
https://github.com/hnakamur/go-scp/blob/master/source.go#L74
func (s *SCP) SendDir(srcDir, destDir string, acceptFn AcceptFunc) error { srcDir = filepath.Clean(srcDir) destDir = filepath.Clean(destDir)
On Windows , filepath.Clean("/remote/path") return \remote\path. (This value will be used later for starting SCP connection, ex: scp -rtp '\remote\path')
filepath.Clean("/remote/path")
scp -rtp '\remote\path'
so, when running on Windows, you should replace \ to / on remote path.
\
/
Thanks for your pull request!
This PR will fix to path separator problems when used on Windows.
If you run like following on Windows, it will create a file
\remote\path
on remote.But what you need is a directory
/remote/path
.The cause is using
filepath.Clean
as following:https://github.com/hnakamur/go-scp/blob/master/source.go#L74
On Windows ,
filepath.Clean("/remote/path")
return\remote\path
. (This value will be used later for starting SCP connection, ex:scp -rtp '\remote\path'
)so, when running on Windows, you should replace
\
to/
on remote path.