From a243ea63538fb4598ffb85b971ed9e14826cf0e8 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Wed, 24 May 2017 15:39:17 +0100 Subject: [PATCH] sftp: fix under Windows #1432 This was caused by erroneous use of filepath to parse unix standard paths --- sftp/sftp.go | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/sftp/sftp.go b/sftp/sftp.go index ed6734204..23ba7eadb 100644 --- a/sftp/sftp.go +++ b/sftp/sftp.go @@ -9,16 +9,14 @@ import ( "net" "os" "path" - "path/filepath" "sync" "time" - "golang.org/x/crypto/ssh" - "golang.org/x/crypto/ssh/agent" - "github.com/ncw/rclone/fs" "github.com/pkg/errors" "github.com/pkg/sftp" + "golang.org/x/crypto/ssh" + "golang.org/x/crypto/ssh/agent" ) func init() { @@ -323,27 +321,27 @@ func (f *Fs) mkParentDir(remote string) error { } // mkdir makes the directory and parents using native paths -func (f *Fs) mkdir(path string) error { - f.mkdirLock.Lock(path) - defer f.mkdirLock.Unlock(path) - if path == "." || path == "/" { +func (f *Fs) mkdir(dirPath string) error { + f.mkdirLock.Lock(dirPath) + defer f.mkdirLock.Unlock(dirPath) + if dirPath == "." || dirPath == "/" { return nil } - ok, err := f.dirExists(path) + ok, err := f.dirExists(dirPath) if err != nil { return errors.Wrap(err, "mkdir dirExists failed") } if ok { return nil } - parent := filepath.Dir(path) + parent := path.Dir(dirPath) err = f.mkdir(parent) if err != nil { return err } - err = f.sftpClient.Mkdir(path) + err = f.sftpClient.Mkdir(dirPath) if err != nil { - return errors.Wrapf(err, "mkdir %q failed", path) + return errors.Wrapf(err, "mkdir %q failed", dirPath) } return nil }