Reserved directory for public interface now lives in public instead of _public
This commit is contained in:
parent
0259ae8f94
commit
469415b40a
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user