Skip to content

Commit

Permalink
add some log
Browse files Browse the repository at this point in the history
  • Loading branch information
codeskyblue committed May 11, 2017
1 parent a95e388 commit 68654f8
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions httpstaticserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,15 @@ func (s *HTTPStaticServer) hUpload(w http.ResponseWriter, req *http.Request) {

file, header, err := req.FormFile("file")
if err != nil {
log.Println("Parse form file:", err)
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
defer file.Close()
dst, err := os.Create(filepath.Join(dirpath, header.Filename)) // BUG(ssx): There is a leak here
dst, err := os.Create(filepath.Join(dirpath, header.Filename))
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
log.Println("Create file:", err)
http.Error(w, "File create "+err.Error(), http.StatusInternalServerError)
return
}
defer dst.Close()
Expand All @@ -158,7 +160,6 @@ func (s *HTTPStaticServer) hUpload(w http.ResponseWriter, req *http.Request) {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
// runtime.GC()
w.Write([]byte("Upload success"))
}

Expand Down

0 comments on commit 68654f8

Please sign in to comment.