Reserved directory for public interface now lives in public instead of _public

This commit is contained in:
nemunaire 2018-01-21 15:03:33 +01:00
parent 0259ae8f94
commit 469415b40a
3 changed files with 8 additions and 8 deletions

View File

@ -54,15 +54,15 @@ func savePublicTo(path string, s []FICPublicScene) error {
}
func getPublic(ps httprouter.Params, body []byte) (interface{}, error) {
if _, err := os.Stat(path.Join(TeamsDir, "_public", fmt.Sprintf("public%s.json", ps.ByName("sid")))); !os.IsNotExist(err) {
return readPublic(path.Join(TeamsDir, "_public", fmt.Sprintf("public%s.json", ps.ByName("sid"))))
if _, err := os.Stat(path.Join(TeamsDir, "public", fmt.Sprintf("public%s.json", ps.ByName("sid")))); !os.IsNotExist(err) {
return readPublic(path.Join(TeamsDir, "public", fmt.Sprintf("public%s.json", ps.ByName("sid"))))
} else {
return []FICPublicScene{}, nil
}
}
func deletePublic(ps httprouter.Params, body []byte) (interface{}, error) {
if err := savePublicTo(path.Join(TeamsDir, "_public", fmt.Sprintf("public%s.json", ps.ByName("sid"))), []FICPublicScene{}); err != nil {
if err := savePublicTo(path.Join(TeamsDir, "public", fmt.Sprintf("public%s.json", ps.ByName("sid"))), []FICPublicScene{}); err != nil {
return nil, err
} else {
return []FICPublicScene{}, err
@ -75,13 +75,13 @@ func savePublic(ps httprouter.Params, body []byte) (interface{}, error) {
return nil, err
}
if _, err := os.Stat(path.Join(TeamsDir, "_public")); os.IsNotExist(err) {
if err := os.Mkdir(path.Join(TeamsDir, "_public"), 0750); err != nil {
if _, err := os.Stat(path.Join(TeamsDir, "public")); os.IsNotExist(err) {
if err := os.Mkdir(path.Join(TeamsDir, "public"), 0750); err != nil {
return nil, err
}
}
if err := savePublicTo(path.Join(TeamsDir, "_public", fmt.Sprintf("public%s.json", ps.ByName("sid"))), scenes); err != nil {
if err := savePublicTo(path.Join(TeamsDir, "public", fmt.Sprintf("public%s.json", ps.ByName("sid"))), scenes); err != nil {
return nil, err
} else {
return scenes, err

View File

@ -54,7 +54,7 @@ func genTeamMyFile(team fic.Team) error {
// Generate public my.json file
func genMyPublicFile() error {
dirPath := path.Join(TeamsDir, "_public")
dirPath := path.Join(TeamsDir, "public")
if s, err := os.Stat(dirPath); os.IsNotExist(err) {
os.MkdirAll(dirPath, 0777)

View File

@ -55,7 +55,7 @@ func (c submissionTeamChecker) ServeHTTP(w http.ResponseWriter, r *http.Request)
team := sURL[0]
// Check team validity and existance
if len(team) < 1 || team[0] == '_' {
if len(team) < 1 || team == "public" {
log.Println("INVALID TEAM:", team)
http.Error(w, "{\"errmsg\":\"Équipe inexistante.\"}", http.StatusBadRequest)
return