0
0
Fork 0
mirror of https://github.com/schollz/croc.git synced 2025-10-11 21:30:16 +02:00

#431 fixed remote folder name for Windows

This commit is contained in:
RCL98 2022-02-21 21:50:24 +02:00
parent 32a188fa85
commit 7c1a59c102

View file

@ -258,7 +258,6 @@ func GetFilesInfo(fnames []string) (filesInfo []FileInfo, err error) {
} }
absPath, errAbs := filepath.Abs(path) absPath, errAbs := filepath.Abs(path)
absPath = filepath.ToSlash(absPath)
if errAbs != nil { if errAbs != nil {
err = errAbs err = errAbs
@ -272,10 +271,12 @@ func GetFilesInfo(fnames []string) (filesInfo []FileInfo, err error) {
return err return err
} }
if !info.IsDir() { if !info.IsDir() {
remoteFolder := strings.TrimPrefix(filepath.Dir(pathName),
filepath.Dir(absPath)+string(os.PathSeparator))
filesInfo = append(filesInfo, FileInfo{ filesInfo = append(filesInfo, FileInfo{
Name: info.Name(), Name: info.Name(),
FolderRemote: strings.TrimPrefix(filepath.Dir(filepath.ToSlash(pathName)), FolderRemote: strings.Replace(remoteFolder, string(os.PathSeparator), "/", -1) + "/",
filepath.Dir(absPath)+"/"),
FolderSource: filepath.Dir(pathName), FolderSource: filepath.Dir(pathName),
Size: info.Size(), Size: info.Size(),
ModTime: info.ModTime(), ModTime: info.ModTime(),
@ -1601,7 +1602,7 @@ func (c *Client) sendData(i int) {
n, errRead := c.fread.ReadAt(data, readingPos) n, errRead := c.fread.ReadAt(data, readingPos)
// log.Debugf("%d read %d bytes", i, n) // log.Debugf("%d read %d bytes", i, n)
readingPos += int64(n) readingPos += int64(n)
if (c.limiter != nil) { if c.limiter != nil {
r := c.limiter.ReserveN(time.Now(), n) r := c.limiter.ReserveN(time.Now(), n)
log.Debugf("Limiting Upload for %d", r.Delay()) log.Debugf("Limiting Upload for %d", r.Delay())
time.Sleep(r.Delay()) time.Sleep(r.Delay())