This commit is contained in:
nemunaire 2016-01-23 13:19:28 +01:00
parent 8788eea4f0
commit 645f40f0c6
8 changed files with 32 additions and 37 deletions

View File

@ -44,7 +44,7 @@ func createExerciceFile(theme fic.Theme, exercice fic.Exercice, args []string, b
return exercice.ImportFile(pathname, uf.URI)
}
func getCloudFile(pathname string, dest string) (error) {
func getCloudFile(pathname string, dest string) error {
client := http.Client{}
if req, err := http.NewRequest("GET", CloudDAVBase+pathname, nil); err != nil {
return err
@ -58,7 +58,7 @@ func getCloudFile(pathname string, dest string) (error) {
if fd, err := os.Create(dest); err != nil {
return err
} else {
defer fd.Close();
defer fd.Close()
if resp.StatusCode != http.StatusOK {
return errors.New(resp.Status)

View File

@ -20,7 +20,6 @@ func (s SubmissionHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
// Check request type and size
if r.Method != "POST" {
http.Error(w, "{\"errmsg\":\"Requête invalide.\"}", http.StatusBadRequest)
@ -30,7 +29,6 @@ func (s SubmissionHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
return
}
// Extract URL arguments
var sURL = strings.Split(r.URL.Path, "/")
@ -61,14 +59,12 @@ func (s SubmissionHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}
}
// Previous submission not treated
if _, err := os.Stat(path.Join(SubmissionDir, fmt.Sprintf("%d", team), fmt.Sprintf("%d", exercice))); !os.IsNotExist(err) {
http.Error(w, "{\"errmsg\":\"Du calme ! une tentative est déjà en cours de traitement.\"}", http.StatusPaymentRequired)
return
}
// Read request body
var body []byte
if r.ContentLength > 0 {
@ -84,7 +80,6 @@ func (s SubmissionHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}
}
// Store content in file
if file, err := os.Create(path.Join(SubmissionDir, fmt.Sprintf("%d", team), fmt.Sprintf("%d", exercice))); err != nil {
log.Println("Unable to open exercice file:", err)