From 7c1a59c1022e3819b838512cb1a1b9e0e1e9a540 Mon Sep 17 00:00:00 2001 From: RCL98 <48773399+RCL98@users.noreply.github.com> Date: Mon, 21 Feb 2022 21:50:24 +0200 Subject: [PATCH] #431 fixed remote folder name for Windows --- src/croc/croc.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/croc/croc.go b/src/croc/croc.go index 2cdedb5e..6b4532f7 100644 --- a/src/croc/croc.go +++ b/src/croc/croc.go @@ -258,7 +258,6 @@ func GetFilesInfo(fnames []string) (filesInfo []FileInfo, err error) { } absPath, errAbs := filepath.Abs(path) - absPath = filepath.ToSlash(absPath) if errAbs != nil { err = errAbs @@ -272,10 +271,12 @@ func GetFilesInfo(fnames []string) (filesInfo []FileInfo, err error) { return err } if !info.IsDir() { + + remoteFolder := strings.TrimPrefix(filepath.Dir(pathName), + filepath.Dir(absPath)+string(os.PathSeparator)) filesInfo = append(filesInfo, FileInfo{ - Name: info.Name(), - FolderRemote: strings.TrimPrefix(filepath.Dir(filepath.ToSlash(pathName)), - filepath.Dir(absPath)+"/"), + Name: info.Name(), + FolderRemote: strings.Replace(remoteFolder, string(os.PathSeparator), "/", -1) + "/", FolderSource: filepath.Dir(pathName), Size: info.Size(), ModTime: info.ModTime(), @@ -1601,7 +1602,7 @@ func (c *Client) sendData(i int) { n, errRead := c.fread.ReadAt(data, readingPos) // log.Debugf("%d read %d bytes", i, n) readingPos += int64(n) - if (c.limiter != nil) { + if c.limiter != nil { r := c.limiter.ReserveN(time.Now(), n) log.Debugf("Limiting Upload for %d", r.Delay()) time.Sleep(r.Delay())