From 533434fe43baaabb73b219086f9c2b602afdeb33 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Fri, 5 Sep 2014 11:24:53 +0800 Subject: [PATCH] . --- conf/wide.go | 8 ++++++++ file/files.go | 8 ++++---- output/outputs.go | 2 +- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/conf/wide.go b/conf/wide.go index 64d5ecf..51fbb3c 100644 --- a/conf/wide.go +++ b/conf/wide.go @@ -36,6 +36,14 @@ type conf struct { var Wide conf var rawWide conf +func (this *conf) GetWorkspace() string { + return filepath.FromSlash(this.Workspace) +} + +func (this *conf) GetUserWorkspace(username string) string { + return filepath.FromSlash(this.UserWorkspaces) + string(os.PathSeparator) + username +} + func Save() bool { // 可变部分 rawWide.Users = Wide.Users diff --git a/file/files.go b/file/files.go index 75a3839..f4dcb0d 100644 --- a/file/files.go +++ b/file/files.go @@ -21,12 +21,12 @@ func GetFiles(w http.ResponseWriter, r *http.Request) { session, _ := user.Session.Get(r, "wide-session") username := session.Values["username"].(string) - userRepos := conf.Wide.UserWorkspaces + string(os.PathSeparator) + username + string(os.PathSeparator) + "src" + userSrc := conf.Wide.GetUserWorkspace(username) + string(os.PathSeparator) + "src" - root := FileNode{"projects", userRepos, "d", []*FileNode{}} - fileInfo, _ := os.Lstat(userRepos) + root := FileNode{"projects", userSrc, "d", []*FileNode{}} + fileInfo, _ := os.Lstat(userSrc) - walk(userRepos, fileInfo, &root) + walk(userSrc, fileInfo, &root) data["root"] = root } diff --git a/output/outputs.go b/output/outputs.go index f73697b..ef4467c 100644 --- a/output/outputs.go +++ b/output/outputs.go @@ -231,7 +231,7 @@ func BuildHandler(w http.ResponseWriter, r *http.Request) { } func setCmdEnv(cmd *exec.Cmd, username string) { - userWorkspace := conf.Wide.UserWorkspaces + string(os.PathSeparator) + username + userWorkspace := conf.Wide.GetUserWorkspace(username) cmd.Env = append(cmd.Env, "GOPATH="+userWorkspace,