error when sync dest to nonexistant root directory on windows

oops
diff --git a/lib/fs/basicfs_windows.go b/lib/fs/basicfs_windows.go
index c4b56de02..87d146d2b 100644
--- a/lib/fs/basicfs_windows.go
+++ b/lib/fs/basicfs_windows.go
@@ -42,11 +42,11 @@ func (f *BasicFilesystem) MkdirAll(path string, perm FileMode) error {
 		return err
 	}
 
-	return f.mkdirAll(path, os.FileMode(perm))
+	return f.mkdirAll(path, perm)
 }
 
 // Required due to https://github.com/golang/go/issues/10900
-func (f *BasicFilesystem) mkdirAll(path string, perm os.FileMode) error {
+func (f *BasicFilesystem) mkdirAll(path string, perm FileMode) error {
 	// Fast path: if we can tell whether path is a directory or file, stop with success or error.
 	dir, err := os.Stat(path)
 	if err == nil {
@@ -74,8 +74,9 @@ func (f *BasicFilesystem) mkdirAll(path string, perm os.FileMode) error {
 	if j > 1 {
 		// Create parent
 		parent := path[0 : j-1]
+		l.Infoln("Volume name check", parent, filepath.VolumeName(parent))
 		if parent != filepath.VolumeName(parent) {
-			err = os.MkdirAll(parent, perm)
+			err = f.mkdirAll(parent, perm)
 			if err != nil {
 				return err
 			}
@@ -83,7 +84,7 @@ func (f *BasicFilesystem) mkdirAll(path string, perm os.FileMode) error {
 	}
 
 	// Parent now exists; invoke Mkdir and use its result.
-	err = os.Mkdir(path, perm)
+	err = os.Mkdir(path, os.FileMode(perm))
 	if err != nil {
 		// Handle arguments like "foo/." by
 		// double-checking that directory doesn't exist.

I patched at home, and on first sight it looks good. Have to enter debug info and test again. Be back later.

1 Like

We should move further discussion to your bug report, as it is now pretty much proven to be a bug :slight_smile: Fails to create folder root directory on Windows ยท Issue #4762 ยท syncthing/syncthing ยท GitHub
I filed a PR to get buildable diffs: lib/fs: Fix MkdirAll failure due to \\?\ by imsodin ยท Pull Request #4763 ยท syncthing/syncthing ยท GitHub

1 Like

Solved. Should be fixed in v0.14.46 .

Thanks!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.