error when sync dest to nonexistant root directory on windows


(Peter Marquardt) #21
oops

(Simon) #22
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.

(Peter Marquardt) #23

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


(Simon) #24

We should move further discussion to your bug report, as it is now pretty much proven to be a bug :slight_smile: https://github.com/syncthing/syncthing/issues/4762
I filed a PR to get buildable diffs: https://github.com/syncthing/syncthing/pull/4763


(Peter Marquardt) #25

Solved. Should be fixed in v0.14.46 .

Thanks!


(system) #26

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