Skip to content

Commit

Permalink
fix egor crashes when work dir exists already
Browse files Browse the repository at this point in the history
  • Loading branch information
chermehdi committed Mar 14, 2020
1 parent d55e9c1 commit 8159d6a
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions commands/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,10 @@ func (judge *JavaJudge) Setup() error {
return err
}
workDirPath := path.Join(currentDir, "work")
if err = os.Mkdir(workDirPath, 0777); err != nil {
return err
if _, err = os.Stat(workDirPath); os.IsNotExist(err) {
if err := os.Mkdir(workDirPath, 0777); err != nil {
return err
}
}
//TODO(chermehdi): make the executables path configurable #14
// Compilation for Java
Expand Down Expand Up @@ -299,8 +301,10 @@ func (judge *CppJudge) Setup() error {
return err
}
workDirPath := path.Join(currentDir, "work")
if err = os.Mkdir(workDirPath, 0777); err != nil {
return err
if _, err = os.Stat(workDirPath); os.IsNotExist(err) {
if err := os.Mkdir(workDirPath, 0777); err != nil {
return err
}
}
var stderrBuffer bytes.Buffer
cmd := exec.Command("g++", judge.Meta.TaskFile, "-o", "work/sol")
Expand Down

0 comments on commit 8159d6a

Please sign in to comment.