Conversation
2025/12/26 15:17:20 rsyncos.go:32: remote protocol: 31
2025/12/26 15:17:20 rsyncos.go:32: sender(paths=["C:\\Users\\yyy\\Desktop\\rsync\\111\\gg"])
2025/12/26 15:17:20 do.go:43: SendFileList(modPath="\\\\?\\", paths=["C:\\Users\\yyy\\Desktop\\rsync\\111\\gg"])
2025/12/26 15:17:20 flist.go:345: sendFileList()
2025/12/26 15:17:20 flist.go:360: path "C:\\Users\\yyy\\Desktop\\rsync\\111\\gg" (local dir "\\\\?\\")
2025/12/26 15:17:20 flist.go:371: filepath.Walk("\\\\?\\C:\\Users\\yyy\\Desktop\\rsync\\111\\gg"), strip="\\\\?\\C:\\Users\\yyy\\Desktop\\rsync\\111\\"
2025/12/26 15:17:20 flist.go:372: prefix="\\gg/"
2025/12/26 15:17:20 flist.go:141: filepath.WalkFn(path=.)
2025/12/26 15:17:20 flist.go:152: isDir=true, xferDirs=1
2025/12/26 15:17:20 flist.go:162: Trim(path=".") = "\\gg/."
2025/12/26 15:17:20 flist.go:141: filepath.WalkFn(path=11.txt)
2025/12/26 15:17:20 flist.go:152: isDir=false, xferDirs=1
2025/12/26 15:17:20 flist.go:162: Trim(path="11.txt") = "\\gg/11.txt"
2025/12/26 15:17:20 do.go:51: file list sent
2025/12/26 15:17:20 rsyncos.go:32: info: \gg/
stapelberg
left a comment
There was a problem hiding this comment.
Thank you for your contribution! Is there already a test in the test suite which starts passing with your changes? If not, could you add a test that triggers the bug please?
| strip := filepath.Dir(filepath.Clean(root)) + sep | ||
| if strings.HasSuffix(requested, sep) { | ||
|
|
||
| isEndSep := strings.HasSuffix(requested, "\\") || strings.HasSuffix(requested, "/") |
There was a problem hiding this comment.
I don’t understand why you had to make this change? os.PathSeparator is defined as / on Linux (see https://pkg.go.dev/os#PathSeparator) and \\ on Windows (see https://pkg.go.dev/os?GOOS=windows#PathSeparator), so why isn’t that enough?
There was a problem hiding this comment.
On Windows systems, paths can use either \ or /
| // st.Logger.Printf("root=%q, strip=%q", root, strip) | ||
| prefix := strings.TrimPrefix(rootPath, filepath.Clean(strip)) | ||
| if prefix != "" { | ||
| prefix = strings.TrimPrefix(prefix, "/") |
There was a problem hiding this comment.
Can we use os.PathSeparator here instead?
There was a problem hiding this comment.
Trailing slash on the source directory:
With a slash: sync the contents of the directory
Without a slash: sync the directory itself
| // Trailing slashes are meaningful to rsync, | ||
| // so preserve a trailing slash across filepath.Abs. | ||
| hasTrailingSlash := strings.HasSuffix(path, "/") | ||
| hasTrailingSlash := strings.HasSuffix(path, "/") || strings.HasSuffix(path, "\\") |
There was a problem hiding this comment.
Can we use os.PathSeparator here instead?
There was a problem hiding this comment.
When I use gokrazy-rsync on Windows and rsync on Linux, even if the path ends with a separator, the Linux server still creates the path.
This bug is easy to reproduce. On a Windows system, sync a directory to a Linux server, using rsync on the Linux server and gokr-rsync.exe on Windows.
|
Command:
C:\Users\yyy\Desktop\rsync\111\gokr-rsync.exe -av C:\Users\yyy\Desktop\rsync\111\gg ...server
Log:
2025/12/26 15:17:20 rsyncos.go:32: remote protocol: 31
2025/12/26 15:17:20 rsyncos.go:32: sender(paths=["C:\Users\yyy\Desktop\rsync\111\gg"])
2025/12/26 15:17:20 do.go:43: SendFileList(modPath="\\?\", paths=["C:\Users\yyy\Desktop\rsync\111\gg"])
2025/12/26 15:17:20 flist.go:345: sendFileList()
2025/12/26 15:17:20 flist.go:360: path "C:\Users\yyy\Desktop\rsync\111\gg" (local dir "\\?\")
2025/12/26 15:17:20 flist.go:371: filepath.Walk("\\?\C:\Users\yyy\Desktop\rsync\111\gg"), strip="\\?\C:\Users\yyy\Desktop\rsync\111\"
2025/12/26 15:17:20 flist.go:372: prefix="\gg/"
2025/12/26 15:17:20 flist.go:141: filepath.WalkFn(path=.)
2025/12/26 15:17:20 flist.go:152: isDir=true, xferDirs=1
2025/12/26 15:17:20 flist.go:162: Trim(path=".") = "\gg/."
2025/12/26 15:17:20 flist.go:141: filepath.WalkFn(path=11.txt)
2025/12/26 15:17:20 flist.go:152: isDir=false, xferDirs=1
2025/12/26 15:17:20 flist.go:162: Trim(path="11.txt") = "\gg/11.txt"
2025/12/26 15:17:20 do.go:51: file list sent
2025/12/26 15:17:20 rsyncos.go:32: info: \gg/
Server:
