Skip to content

Commit

Permalink
bugfix file not close for tmp file
Browse files Browse the repository at this point in the history
  • Loading branch information
sjqzhang committed Jun 9, 2020
1 parent 7a5e46c commit f4f35b6
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions fileserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -2400,11 +2400,15 @@ func (this *Server) Upload(w http.ResponseWriter, r *http.Request) {
}
r.Body = fpBody
defer func() {
fpBody.Close()
os.Remove(fn)
err = fpBody.Close()
if err != nil {
log.Error(err)
}
err = os.Remove(fn)
if err != nil {
log.Error(err)
}
}()
fpBody, err = os.Open(fn)
r.Body = fpBody
done := make(chan bool, 1)
this.queueUpload <- WrapReqResp{&w, r, done}
<-done
Expand Down

0 comments on commit f4f35b6

Please sign in to comment.