Make go vet -strictshadow mostly happy
This commit is contained in:
parent
75463dcebb
commit
8749a7c164
7 changed files with 38 additions and 35 deletions
|
@ -34,7 +34,7 @@ func main() {
|
|||
|
||||
log.Println("Creating submission directory...")
|
||||
if _, err := os.Stat(TmpSubmissionDir); os.IsNotExist(err) {
|
||||
if err := os.MkdirAll(TmpSubmissionDir, 0700); err != nil {
|
||||
if err = os.MkdirAll(TmpSubmissionDir, 0700); err != nil {
|
||||
log.Fatal("Unable to create submission directory: ", err)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ func (s ResolutionHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
if resolutionTmpl, err := template.New("resolution").Parse(resolutiontpl); err != nil {
|
||||
log.Println("Cannot create template: ", err)
|
||||
} else if err := resolutionTmpl.Execute(w, path.Join("/vids/", r.URL.Path)); err != nil {
|
||||
} else if err = resolutionTmpl.Execute(w, path.Join("/vids/", r.URL.Path)); err != nil {
|
||||
log.Println("An error occurs during template execution: ", err)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ func saveTeamFile(p string, w http.ResponseWriter, r *http.Request) bool {
|
|||
// Previous submission not treated
|
||||
http.Error(w, "{\"errmsg\":\"Du calme ! une requête est déjà en cours de traitement.\"}", http.StatusPaymentRequired)
|
||||
return false
|
||||
} else if err := saveFile(path.Join(SubmissionDir, p), r); err != nil {
|
||||
} else if err = saveFile(path.Join(SubmissionDir, p), r); err != nil {
|
||||
log.Println("Unable to handle submission file:", err)
|
||||
http.Error(w, "{\"errmsg\":\"Internal server error. Please retry in few seconds.\"}", http.StatusInternalServerError)
|
||||
return false
|
||||
|
@ -35,7 +35,7 @@ func saveTeamFile(p string, w http.ResponseWriter, r *http.Request) bool {
|
|||
func saveFile(p string, r *http.Request) error {
|
||||
dirname := path.Dir(p)
|
||||
if _, err := os.Stat(dirname); os.IsNotExist(err) {
|
||||
if err := os.MkdirAll(dirname, 0755); err != nil {
|
||||
if err = os.MkdirAll(dirname, 0755); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
@ -48,13 +48,13 @@ func saveFile(p string, r *http.Request) error {
|
|||
|
||||
writer := bufio.NewWriter(tmpfile)
|
||||
reader := bufio.NewReader(r.Body)
|
||||
if _, err := reader.WriteTo(writer); err != nil {
|
||||
if _, err = reader.WriteTo(writer); err != nil {
|
||||
return err
|
||||
}
|
||||
writer.Flush()
|
||||
tmpfile.Close()
|
||||
|
||||
if err := os.Rename(tmpfile.Name(), p); err != nil {
|
||||
if err = os.Rename(tmpfile.Name(), p); err != nil {
|
||||
log.Println("[ERROR] Unable to move file: ", err)
|
||||
return err
|
||||
}
|
||||
|
|
Reference in a new issue