mirror of
https://github.com/rclone/rclone.git
synced 2024-11-25 09:41:44 +08:00
local: fix cleanRootPath on Windows after go1.21.4 stdlib update
Similar to
acf1e2df84
,
go1.21.4 appears to have broken sync.MoveDir on Windows because
filepath.VolumeName() returns `\\?` instead of `\\?\C:` in cleanRootPath. It
looks like the Go team is aware of the issue and planning a fix, so this may
only be needed temporarily.
This commit is contained in:
parent
bbf9b1b3d2
commit
7f854acb05
|
@ -1447,6 +1447,10 @@ func cleanRootPath(s string, noUNC bool, enc encoder.MultiEncoder) string {
|
|||
if runtime.GOOS == "windows" {
|
||||
s = filepath.ToSlash(s)
|
||||
vol := filepath.VolumeName(s)
|
||||
if vol == `\\?` && len(s) >= 6 {
|
||||
// `\\?\C:`
|
||||
vol = s[:6]
|
||||
}
|
||||
s = vol + enc.FromStandardPath(s[len(vol):])
|
||||
s = filepath.FromSlash(s)
|
||||
if !noUNC {
|
||||
|
|
|
@ -1351,6 +1351,22 @@ func testServerSideMove(ctx context.Context, t *testing.T, r *fstest.Run, withFi
|
|||
}
|
||||
}
|
||||
|
||||
// Test MoveDir on Local
|
||||
func TestServerSideMoveLocal(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
r := fstest.NewRun(t)
|
||||
f1 := r.WriteFile("dir1/file1.txt", "hello", t1)
|
||||
f2 := r.WriteFile("dir2/file2.txt", "hello again", t2)
|
||||
r.CheckLocalItems(t, f1, f2)
|
||||
|
||||
dir1, err := fs.NewFs(ctx, r.Flocal.Root()+"/dir1")
|
||||
require.NoError(t, err)
|
||||
dir2, err := fs.NewFs(ctx, r.Flocal.Root()+"/dir2")
|
||||
require.NoError(t, err)
|
||||
err = MoveDir(ctx, dir2, dir1, false, false)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
// Test move
|
||||
func TestMoveWithDeleteEmptySrcDirs(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
|
Loading…
Reference in New Issue
Block a user