修复文件树异步构建问题

This commit is contained in:
Liang Ding 2014-09-16 21:20:12 +08:00
parent 7c69764aed
commit f5ff038910
1 changed files with 12 additions and 12 deletions

View File

@ -33,25 +33,25 @@ func GetFiles(w http.ResponseWriter, r *http.Request) {
// 构造 Go API 节点
apiPath := runtime.GOROOT() + string(os.PathSeparator) + "src" + string(os.PathSeparator) + "pkg"
apiNode := FileNode{Name: "Go API", Path: apiPath, FileNodes: []*FileNode{}}
goapiBuildOKSignal := make(chan bool)
go func() {
fio, _ := os.Lstat(apiPath)
if fio.IsDir() {
apiNode.Type = "d"
// TOOD: Go API 用另外的样式
apiNode.IconSkin = "ico-ztree-dir "
walk(apiPath, &apiNode)
} else {
apiNode.Type = "f"
ext := filepath.Ext(apiPath)
apiNode.IconSkin = getIconSkin(ext)
apiNode.Mode = getEditorMode(ext)
}
// 放行信号
close(goapiBuildOKSignal)
}()
// 构造用户工作空间文件树
walk(userSrc, &root)
// 等待放行
<-goapiBuildOKSignal
// 添加 Go API 节点
root.FileNodes = append(root.FileNodes, &apiNode)