🎨 Cleanup code
This commit is contained in:
parent
11dbe42c9a
commit
efcceccac4
17
conf/wide.go
17
conf/wide.go
|
@ -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() {
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue