frontend: avoid RW access to TEAMS dir by placing startedFile into submissions

This commit is contained in:
nemunaire 2017-11-10 20:53:49 +01:00 committed by Pierre-Olivier Mercier
parent df5c9532cd
commit def822cd45
2 changed files with 5 additions and 4 deletions

View File

@ -14,7 +14,7 @@ import (
// Check if the challenge is started or not
func isStarted() bool {
if _, err := os.Stat(path.Join(TeamsDir, "started")); os.IsNotExist(err) {
if _, err := os.Stat(path.Join(SubmissionDir, "started")); os.IsNotExist(err) {
return false
}
return true
@ -38,6 +38,7 @@ func genTeamMyFile(team fic.Team) error {
return err
}
// Speed up generation when challenge is started
if !isStarted() {
if my, err := fic.MyJSONTeam(&team, false); err != nil {
return err

View File

@ -22,7 +22,7 @@ var TmpSubmissionDir string
var touchTimer *time.Timer = nil
func touchStartedFile() {
if fd, err := os.Create(path.Join(TeamsDir, startedFile)); err == nil {
if fd, err := os.Create(path.Join(SubmissionDir, startedFile)); err == nil {
log.Println("Started! Go, Go, Go!!")
fd.Close()
} else {
@ -39,8 +39,8 @@ func reloadSettings(config settings.FICSettings) {
if startSub > 0 {
log.Println("Challenge will starts at", config.Start, "in", startSub)
if _, err := os.Stat(path.Join(TeamsDir, startedFile)); !os.IsNotExist(err) {
os.Remove(path.Join(TeamsDir, startedFile))
if _, err := os.Stat(path.Join(SubmissionDir, startedFile)); !os.IsNotExist(err) {
os.Remove(path.Join(SubmissionDir, startedFile))
}
touchTimer = time.AfterFunc(config.Start.Sub(time.Now().Add(time.Duration(1 * time.Second))), touchStartedFile)