engine: resources: Close files after use
Don't need to wait for gc.
This commit is contained in:
@@ -247,6 +247,7 @@ func (obj *HTTPServerRes) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
|||||||
sendHTTPError(w, err)
|
sendHTTPError(w, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
defer handle.Close() // ignore error
|
||||||
|
|
||||||
// Determine the last-modified time if we can.
|
// Determine the last-modified time if we can.
|
||||||
modtime := time.Now()
|
modtime := time.Now()
|
||||||
@@ -969,6 +970,12 @@ func (obj *HTTPFileRes) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
|||||||
sendHTTPError(w, err)
|
sendHTTPError(w, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
//if readSeekCloser, ok := handle.(io.ReadSeekCloser); ok { // same
|
||||||
|
// defer readSeekCloser.Close() // ignore error
|
||||||
|
//}
|
||||||
|
if closer, ok := handle.(io.Closer); ok {
|
||||||
|
defer closer.Close() // ignore error
|
||||||
|
}
|
||||||
|
|
||||||
// Determine the last-modified time if we can.
|
// Determine the last-modified time if we can.
|
||||||
modtime := time.Now()
|
modtime := time.Now()
|
||||||
|
|||||||
Reference in New Issue
Block a user