Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

local: fix cleanRootPath on Windows after go1.21.4 stdlib update

nielash7f854acb0569
diff --git a/backend/local/local.go b/backend/local/local.go
index c444267f1..832390d5a 100644
--- a/backend/local/local.go
+++ b/backend/local/local.go
@@ -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 {
diff --git a/fs/sync/sync_test.go b/fs/sync/sync_test.go
index 34085ee6e..7911be1d0 100644
--- a/fs/sync/sync_test.go
+++ b/fs/sync/sync_test.go
@@ -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()