engine: resources: Close files after use

Don't need to wait for gc.
This commit is contained in:
James Shubin
2024-02-16 07:33:55 -05:00
parent 87ce637bd2
commit bd708159a1

View File

@@ -247,6 +247,7 @@ func (obj *HTTPServerRes) ServeHTTP(w http.ResponseWriter, req *http.Request) {
sendHTTPError(w, err)
return
}
defer handle.Close() // ignore error
// Determine the last-modified time if we can.
modtime := time.Now()
@@ -969,6 +970,12 @@ func (obj *HTTPFileRes) ServeHTTP(w http.ResponseWriter, req *http.Request) {
sendHTTPError(w, err)
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.
modtime := time.Now()