MCPcopy Create free account
hub / github.com/LanceLRQ/deer-executor / GetSessionDir

Function GetSessionDir

common/utils/session.go:10–27  ·  view source on GitHub ↗

GetSessionDir get or create a session directory

(workDir string, SessionID string)

Source from the content-addressed store, hash-verified

8
9// GetSessionDir get or create a session directory
10func GetSessionDir(workDir string, SessionID string) (string, error) {
11 _, err := os.Stat(workDir)
12 if os.IsNotExist(err) {
13 return "", errors.Errorf("work dir (%s) not exists", workDir)
14 } else if err != nil {
15 return "", err
16 }
17 sessionDir := path.Join(workDir, SessionID)
18 s, err := os.Stat(sessionDir)
19 if s != nil || os.IsExist(err) {
20 _ = os.RemoveAll(sessionDir)
21 }
22 err = os.Mkdir(sessionDir, 0755)
23 if err != nil {
24 return "", errors.Errorf("create session dir error: %s", err.Error())
25 }
26 return sessionDir, nil
27}

Callers 3

initWorkFunction · 0.92
runOnceJudgeFunction · 0.92
runJudgeFunction · 0.92

Calls 2

ErrorfMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected