backend: rely on configuration instead of started file to determine if the challenge is launched or not

This commit is contained in:
nemunaire 2019-01-17 16:48:45 +01:00
parent af1cecd3ce
commit 75463dcebb
2 changed files with 3 additions and 9 deletions

View File

@ -12,14 +12,6 @@ import (
"srs.epita.fr/fic-server/libfic" "srs.epita.fr/fic-server/libfic"
) )
// Check if the challenge is started or not
func isStarted() bool {
if _, err := os.Stat(path.Join(SubmissionDir, "started")); os.IsNotExist(err) {
return false
}
return true
}
// Generate my.json and wait.json for a given team // Generate my.json and wait.json for a given team
func genTeamMyFile(team fic.Team) error { func genTeamMyFile(team fic.Team) error {
dirPath := path.Join(TeamsDir, fmt.Sprintf("%d", team.Id)) dirPath := path.Join(TeamsDir, fmt.Sprintf("%d", team.Id))
@ -39,7 +31,7 @@ func genTeamMyFile(team fic.Team) error {
} }
// Speed up generation when challenge is started // Speed up generation when challenge is started
if !isStarted() { if !ChStarted {
if my, err := fic.MyJSONTeam(&team, false); err != nil { if my, err := fic.MyJSONTeam(&team, false); err != nil {
return err return err
} else if j, err := json.Marshal(my); err != nil { } else if j, err := json.Marshal(my); err != nil {

View File

@ -43,6 +43,7 @@ func watchsubdir(watcher *fsnotify.Watcher, pathname string) error {
} }
} }
var ChStarted = false
var lastRegeneration time.Time var lastRegeneration time.Time
var skipInitialGeneration = false var skipInitialGeneration = false
@ -50,6 +51,7 @@ func reloadSettings(config settings.FICSettings) {
fic.HintCoefficient = config.HintCurCoefficient fic.HintCoefficient = config.HintCurCoefficient
fic.WChoiceCoefficient = config.WChoiceCurCoefficient fic.WChoiceCoefficient = config.WChoiceCurCoefficient
fic.ExerciceCurrentCoefficient = config.ExerciceCurCoefficient fic.ExerciceCurrentCoefficient = config.ExerciceCurCoefficient
ChStarted = time.Since(config.Start) >= 0
if lastRegeneration != config.Generation || fic.PartialValidation != config.PartialValidation || fic.FirstBlood != config.FirstBlood || fic.SubmissionCostBase != config.SubmissionCostBase || fic.SubmissionUniqueness != config.SubmissionUniqueness { if lastRegeneration != config.Generation || fic.PartialValidation != config.PartialValidation || fic.FirstBlood != config.FirstBlood || fic.SubmissionCostBase != config.SubmissionCostBase || fic.SubmissionUniqueness != config.SubmissionUniqueness {
fic.PartialValidation = config.PartialValidation fic.PartialValidation = config.PartialValidation
if config.EnableExerciceDepend { if config.EnableExerciceDepend {