fix: use fspath.Base to strip Windows paths on SSH remote drag-drop#3118
Conversation
When drag-dropping a local Windows file (e.g. D:\package\AA.tar) to an SSH remote, filepath.Base was called on the remote (Linux) side, which does not recognise backslashes as separators and kept the full Windows path as the filename. Replace with fspath.Base, which converts backslashes to forward slashes before extracting the basename. Fixes wavetermdev#3079 Signed-off-by: majiayu000 <1835304752@qq.com>
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Code Review SummaryStatus: No Issues Found | Recommendation: Merge OverviewThe PR correctly fixes the Windows path issue (#3079) by introducing a new Files Reviewed (2 files)
Notes
Reviewed by minimax-m2.5-20260211 · 279,071 tokens |
Fixes #3079
Summary
When dragging a local file from Windows to an SSH remote connection, the full Windows path (e.g.
D:\package\AA.tar) was being passed tofilepath.Baseon the remote (Linux) side. Sincefilepath.Baseon Linux does not recognize backslashes as separators, the full path was used as the destination filename.RemoteFileCopyCommand(wshremote_file.go:159), replacefilepath.Base(srcConn.Path)withfspath.Base(srcConn.Path)fspath.BasecallsToSlashbeforepath.Base, converting backslashes to forward slashes first, soD:\package\AA.tarcorrectly yieldsAA.taron any OSfilepath.Base(srcPathCleaned)and are unaffected — those run on the same OS wherefilepath.Baseis correctTest Plan
pkg/remote/fileshare/fspath/fspath_test.gowith table-driven tests forfspath.Base:D:\package\AA.tar→AA.tarD:/package/AA.tar→AA.tar/home/user/file.txt→file.txtfile.txt→file.txtgo test ./pkg/remote/fileshare/fspath/...passes