🎨 Cleanup code

This commit is contained in:
Liang Ding 2019-05-16 10:52:31 +08:00
parent 11dbe42c9a
commit efcceccac4
No known key found for this signature in database
GPG Key ID: 136F30F901A2231D
2 changed files with 15 additions and 14 deletions

View File

@ -83,14 +83,19 @@ var Wide *conf
// configurations of users.
var Users []*User
// Load loads the Wide configurations from wide.json and users' configurations from users/{username}.json.
func Load(confPath, confIP, confPort, confServer, confLogLevel, confStaticServer, confContext, confChannel,
confPlayground string, confUsersWorkspaces string) {
// XXX: ugly args list....
// Indicates whether Docker is available.
var Docker bool
initWide(confPath, confIP, confPort, confServer, confLogLevel, confStaticServer, confContext, confChannel,
confPlayground, confUsersWorkspaces)
// Load loads the Wide configurations from wide.json and users' configurations from users/{username}.json.
func Load(confPath, confIP, confPort, confServer, confLogLevel, confStaticServer, confContext, confChannel, confPlayground string, confUsersWorkspaces string) {
initWide(confPath, confIP, confPort, confServer, confLogLevel, confStaticServer, confContext, confChannel, confPlayground, confUsersWorkspaces)
initUsers()
cmd := exec.Command("docker", "version")
_, err := cmd.CombinedOutput()
if nil != err {
logger.Warn("Not found 'docker' installed, running user's code will cause security problem")
}
}
func initUsers() {

View File

@ -480,7 +480,7 @@ func (sessions *wSessions) new(httpSession *sessions.Session, sid string) *WideS
for {
ch := SessionWS[sid]
if nil == ch {
return // release this gorutine
return // release this goroutine
}
select {
@ -506,17 +506,13 @@ func (sessions *wSessions) new(httpSession *sessions.Session, sid string) *WideS
}
}
cmd := map[string]interface{}{"path": path, "dir": dir,
"cmd": "create-file", "type": fileType}
cmd := map[string]interface{}{"path": path, "dir": dir, "cmd": "create-file", "type": fileType}
ch.WriteJSON(&cmd)
} else if event.Op&fsnotify.Remove == fsnotify.Remove {
cmd := map[string]interface{}{"path": path, "dir": dir,
"cmd": "remove-file", "type": ""}
cmd := map[string]interface{}{"path": path, "dir": dir, "cmd": "remove-file", "type": ""}
ch.WriteJSON(&cmd)
} else if event.Op&fsnotify.Rename == fsnotify.Rename {
cmd := map[string]interface{}{"path": path, "dir": dir,
"cmd": "rename-file", "type": ""}
cmd := map[string]interface{}{"path": path, "dir": dir, "cmd": "rename-file", "type": ""}
ch.WriteJSON(&cmd)
}
case err := <-watcher.Errors: