diff --git a/handle/handle.go b/handle/handle.go index 019b24c..6205b1b 100644 --- a/handle/handle.go +++ b/handle/handle.go @@ -487,7 +487,7 @@ type simpleFileInfo struct { AbsolutePath string `json:"absolutePath"` } -var gobalFolderFileMap = make(map[string] *simpleFileInfo) +var gobalFolderFileMap map[string] *simpleFileInfo var gobalRelativePath string /** 获取指定目录或文件的文件信息,如果是目录递归获取文件信息 @@ -495,6 +495,7 @@ var gobalRelativePath string */ func GetFolderFileInfo(conn *websocket.Conn,absolutePath string) error{ + gobalFolderFileMap = make(map[string] *simpleFileInfo) fileInfo,err :=os.Stat(absolutePath) if err!=nil{ log.Println(err) @@ -551,7 +552,7 @@ func myWalkfunc(path string, info os.FileInfo, err error) error { simpleFileInfo := new(simpleFileInfo) simpleFileInfo.Name=info.Name() simpleFileInfo.Extension=filepath.Ext(path) - simpleFileInfo.RelativePath=strings.Replace(path,gobalRelativePath,"",1) + simpleFileInfo.RelativePath=filepath.Dir(strings.Replace(path,gobalRelativePath,"",1)) simpleFileInfo.AbsolutePath=path gobalFolderFileMap[path]=simpleFileInfo return nil