add missing File.Close() calls
This commit is contained in:
parent
06f296639e
commit
58b6b1618d
2 changed files with 3 additions and 0 deletions
|
|
@ -103,11 +103,13 @@ func serveMediaDirectory(w http.ResponseWriter, req *http.Request) {
|
||||||
http.Error(w, "is a directory; maybe you are looking for " + path, http.StatusForbidden)
|
http.Error(w, "is a directory; maybe you are looking for " + path, http.StatusForbidden)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
f, err := os.Open(filePath)
|
f, err := os.Open(filePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, "not found", http.StatusNotFound)
|
http.Error(w, "not found", http.StatusNotFound)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
defer f.Close()
|
||||||
util.DoChunks(f, 4, func (buf []byte) { w.Write(buf) })
|
util.DoChunks(f, 4, func (buf []byte) { w.Write(buf) })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ func Dirents(dir string) (entries []string, err error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.New(err.Error())
|
return nil, errors.New(err.Error())
|
||||||
}
|
}
|
||||||
|
defer d.Close()
|
||||||
|
|
||||||
names, err := d.Readdirnames(0)
|
names, err := d.Readdirnames(0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue