frontend: avoid RW access to TEAMS dir by placing startedFile into submissions
This commit is contained in:
parent
df5c9532cd
commit
def822cd45
@ -14,7 +14,7 @@ import (
|
|||||||
|
|
||||||
// Check if the challenge is started or not
|
// Check if the challenge is started or not
|
||||||
func isStarted() bool {
|
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 false
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
@ -38,6 +38,7 @@ func genTeamMyFile(team fic.Team) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Speed up generation when challenge is started
|
||||||
if !isStarted() {
|
if !isStarted() {
|
||||||
if my, err := fic.MyJSONTeam(&team, false); err != nil {
|
if my, err := fic.MyJSONTeam(&team, false); err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -22,7 +22,7 @@ var TmpSubmissionDir string
|
|||||||
var touchTimer *time.Timer = nil
|
var touchTimer *time.Timer = nil
|
||||||
|
|
||||||
func touchStartedFile() {
|
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!!")
|
log.Println("Started! Go, Go, Go!!")
|
||||||
fd.Close()
|
fd.Close()
|
||||||
} else {
|
} else {
|
||||||
@ -39,8 +39,8 @@ func reloadSettings(config settings.FICSettings) {
|
|||||||
if startSub > 0 {
|
if startSub > 0 {
|
||||||
log.Println("Challenge will starts at", config.Start, "in", startSub)
|
log.Println("Challenge will starts at", config.Start, "in", startSub)
|
||||||
|
|
||||||
if _, err := os.Stat(path.Join(TeamsDir, startedFile)); !os.IsNotExist(err) {
|
if _, err := os.Stat(path.Join(SubmissionDir, startedFile)); !os.IsNotExist(err) {
|
||||||
os.Remove(path.Join(TeamsDir, startedFile))
|
os.Remove(path.Join(SubmissionDir, startedFile))
|
||||||
}
|
}
|
||||||
|
|
||||||
touchTimer = time.AfterFunc(config.Start.Sub(time.Now().Add(time.Duration(1 * time.Second))), touchStartedFile)
|
touchTimer = time.AfterFunc(config.Start.Sub(time.Now().Add(time.Duration(1 * time.Second))), touchStartedFile)
|
||||||
|
Loading…
Reference in New Issue
Block a user