Commit 0b29c49
authored
fix: use fspath.Base to strip Windows paths on SSH remote drag-drop (#3118)
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 to
`filepath.Base` on the remote (Linux) side. Since `filepath.Base` on
Linux does not recognize backslashes as separators, the full path was
used as the destination filename.
- In `RemoteFileCopyCommand` (`wshremote_file.go:159`), replace
`filepath.Base(srcConn.Path)` with `fspath.Base(srcConn.Path)`
- `fspath.Base` calls `ToSlash` before `path.Base`, converting
backslashes to forward slashes first, so `D:\package\AA.tar` correctly
yields `AA.tar` on any OS
- Same-host copies at line 86 use `filepath.Base(srcPathCleaned)` and
are unaffected — those run on the same OS where `filepath.Base` is
correct
## Test Plan
- Added `pkg/remote/fileshare/fspath/fspath_test.go` with table-driven
tests for `fspath.Base`:
- Windows path with backslashes: `D:\package\AA.tar` → `AA.tar`
- Windows path with forward slashes: `D:/package/AA.tar` → `AA.tar`
- Unix path: `/home/user/file.txt` → `file.txt`
- Filename only: `file.txt` → `file.txt`
- `go test ./pkg/remote/fileshare/fspath/...` passes
Signed-off-by: majiayu000 <1835304752@qq.com>1 parent 101d09b commit 0b29c49
2 files changed
+23
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
156 | 157 | | |
157 | 158 | | |
158 | 159 | | |
159 | | - | |
| 160 | + | |
160 | 161 | | |
161 | 162 | | |
162 | 163 | | |
| |||
0 commit comments