Remove team's initial_name, replaced by their ID
This commit is contained in:
parent
191c89f7ad
commit
e083da2f72
9 changed files with 26 additions and 65 deletions
|
@ -22,7 +22,7 @@ func isStarted() bool {
|
|||
|
||||
// Generate my.json and wait.json for a given team
|
||||
func genTeamMyFile(team fic.Team) error {
|
||||
dirPath := path.Join(TeamsDir, team.InitialName)
|
||||
dirPath := path.Join(TeamsDir, fmt.Sprintf("%d", team.Id))
|
||||
|
||||
if s, err := os.Stat(dirPath); os.IsNotExist(err) {
|
||||
os.MkdirAll(dirPath, 0777)
|
||||
|
|
|
@ -7,6 +7,7 @@ import (
|
|||
"math/rand"
|
||||
"os"
|
||||
"path"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
|
@ -142,7 +143,9 @@ func treat(raw_path string) {
|
|||
if len(spath) == 3 {
|
||||
if spath[1] == "_registration" {
|
||||
treatRegistration(raw_path, spath[2])
|
||||
} else if team, err := fic.GetTeamByInitialName(spath[1]); err != nil {
|
||||
} else if teamid, err := strconv.Atoi(spath[1]); err != nil {
|
||||
log.Println("[ERR]", err)
|
||||
} else if team, err := fic.GetTeam(teamid); err != nil {
|
||||
log.Println("[ERR]", err)
|
||||
} else if spath[2] == "name" {
|
||||
treatRename(raw_path, team)
|
||||
|
|
|
@ -17,7 +17,7 @@ type uTeamRegistration struct {
|
|||
Members []fic.Member
|
||||
}
|
||||
|
||||
func treatRegistration(pathname string, initial_name string) {
|
||||
func treatRegistration(pathname string, team_id string) {
|
||||
var nTeam uTeamRegistration
|
||||
|
||||
if cnt_raw, err := ioutil.ReadFile(pathname); err != nil {
|
||||
|
@ -25,7 +25,7 @@ func treatRegistration(pathname string, initial_name string) {
|
|||
} else if err := json.Unmarshal(cnt_raw, &nTeam); err != nil {
|
||||
log.Println("[ERR]", err)
|
||||
} else if validTeamName(nTeam.TeamName) {
|
||||
if team, err := fic.RegisterTeam(initial_name, nTeam.TeamName, uint32(rand.Int31n(16581376))); err != nil {
|
||||
if team, err := fic.CreateTeam(nTeam.TeamName, uint32(rand.Int31n(16581376))); err != nil {
|
||||
log.Printf("[ERR] Unable to register new team %s: %s\n", nTeam.TeamName, err)
|
||||
} else {
|
||||
for _, m := range nTeam.Members {
|
||||
|
@ -43,8 +43,13 @@ func treatRegistration(pathname string, initial_name string) {
|
|||
log.Println("[WRN] Unable to create event:", err)
|
||||
}
|
||||
|
||||
os.MkdirAll(path.Join(SubmissionDir, team.InitialName), 0777)
|
||||
os.MkdirAll(path.Join(TeamsDir, team.InitialName), 0777)
|
||||
teamDirPath := path.Join(TeamsDir, fmt.Sprintf("%d", team.Id))
|
||||
if err := os.MkdirAll(teamDirPath, 0777); err != nil {
|
||||
log.Println("[ERR]", err)
|
||||
}
|
||||
if err := os.Symlink(teamDirPath, path.Join(TeamsDir, fmt.Sprintf("_AUTH_ID_%s", team_id))); err != nil {
|
||||
log.Println("[ERR]", err)
|
||||
}
|
||||
|
||||
go func() {
|
||||
if err := genTeamMyFile(team); err != nil {
|
||||
|
|
Reference in a new issue