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

Function loadProblemConfiguration

client/run/common.go:26–65  ·  view source on GitHub ↗
(configFile string, workDir string)

Source from the content-addressed store, hash-verified

24}
25
26func loadProblemConfiguration(configFile string, workDir string) (string, bool, string, error) {
27 _, err := os.Stat(configFile)
28 if err != nil && os.IsNotExist(err) {
29 return "", false, "", errors.Errorf("problem config file (%s) not found", configFile)
30 }
31 isDeerPack, err := utils.IsProblemPackage(configFile)
32 if err != nil {
33 return "", false, "", err
34 }
35 isZipPack, err := utils.IsZipFile(configFile)
36 if err != nil {
37 return "", false, "", err
38 }
39 autoRemoveWorkDir := false
40 // 如果是题目包文件,进行解包,并返回解包后的配置文件位置
41 if isDeerPack || isZipPack {
42 if workDir == "" {
43 workDir = "/tmp/" + uuid.NewV4().String()
44 autoRemoveWorkDir = true
45 }
46 if info, err := os.Stat(workDir); os.IsNotExist(err) {
47 err = os.MkdirAll(workDir, 0755)
48 if err != nil {
49 return "", false, "", err
50 }
51 } else if !info.IsDir() {
52 return "", false, "", errors.Errorf("work dir path cannot be a file path")
53 }
54 if isDeerPack {
55 _, configFile, err = problems.ReadProblemInfo(configFile, true, true, workDir)
56 } else {
57 _, configFile, err = problems.ReadProblemInfoZip(configFile, true, true, workDir)
58 }
59 if err != nil {
60 return "", false, "", err
61 }
62 }
63 // 如果不是题包文件,返回的是配置文件的路径和工作目录,
64 return configFile, autoRemoveWorkDir, workDir, nil
65}

Callers 1

UserRunJudgeFunction · 0.85

Calls 6

IsProblemPackageFunction · 0.92
IsZipFileFunction · 0.92
ReadProblemInfoFunction · 0.92
ReadProblemInfoZipFunction · 0.92
ErrorfMethod · 0.80
StringMethod · 0.65

Tested by

no test coverage detected