Forráskód Böngészése

webdav: use path.Join instead of filepath.Join in walkFS

walkFS is used in TestWalkFS to walk over memFS FileSystem.
memFS uses slash delimited paths, so we must use path,
not filepath, package to construct path elements in walkFS.

Fixes golang/go#10517.

Change-Id: I3632472e5fb0fbaa13e5656d9ae5483e8ec332b2
Reviewed-on: https://go-review.googlesource.com/9193
Reviewed-by: Robert Stepanek <robert.stepanek@gmail.com>
Reviewed-by: Nigel Tao <nigeltao@golang.org>
Alex Brainman 10 éve
szülő
commit
4977ec316d
1 módosított fájl, 7 hozzáadás és 7 törlés
  1. 7 7
      webdav/file.go

+ 7 - 7
webdav/file.go

@@ -673,14 +673,14 @@ func copyFiles(fs FileSystem, src, dst string, overwrite bool, depth int, recurs
 	return http.StatusNoContent, nil
 }
 
-// walkFS traverses filesystem fs starting at path up to depth levels.
+// walkFS traverses filesystem fs starting at name up to depth levels.
 //
 // Allowed values for depth are 0, 1 or infiniteDepth. For each visited node,
 // walkFS calls walkFn. If a visited file system node is a directory and
 // walkFn returns filepath.SkipDir, walkFS will skip traversal of this node.
-func walkFS(fs FileSystem, depth int, path string, info os.FileInfo, walkFn filepath.WalkFunc) error {
+func walkFS(fs FileSystem, depth int, name string, info os.FileInfo, walkFn filepath.WalkFunc) error {
 	// This implementation is based on Walk's code in the standard path/filepath package.
-	err := walkFn(path, info, nil)
+	err := walkFn(name, info, nil)
 	if err != nil {
 		if info.IsDir() && err == filepath.SkipDir {
 			return nil
@@ -695,18 +695,18 @@ func walkFS(fs FileSystem, depth int, path string, info os.FileInfo, walkFn file
 	}
 
 	// Read directory names.
-	f, err := fs.OpenFile(path, os.O_RDONLY, 0)
+	f, err := fs.OpenFile(name, os.O_RDONLY, 0)
 	if err != nil {
-		return walkFn(path, info, err)
+		return walkFn(name, info, err)
 	}
 	fileInfos, err := f.Readdir(0)
 	f.Close()
 	if err != nil {
-		return walkFn(path, info, err)
+		return walkFn(name, info, err)
 	}
 
 	for _, fileInfo := range fileInfos {
-		filename := filepath.Join(path, fileInfo.Name())
+		filename := path.Join(name, fileInfo.Name())
 		fileInfo, err := fs.Stat(filename)
 		if err != nil {
 			if err := walkFn(filename, fileInfo, err); err != nil && err != filepath.SkipDir {