add missing File.Close() calls

This commit is contained in:
Jeremy Baxter 2026-01-05 01:28:24 +13:00
parent 06f296639e
commit 58b6b1618d
2 changed files with 3 additions and 0 deletions

View file

@ -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)
return
}
f, err := os.Open(filePath)
if err != nil {
http.Error(w, "not found", http.StatusNotFound)
return
}
defer f.Close()
util.DoChunks(f, 4, func (buf []byte) { w.Write(buf) })
}

View file

@ -26,6 +26,7 @@ func Dirents(dir string) (entries []string, err error) {
if err != nil {
return nil, errors.New(err.Error())
}
defer d.Close()
names, err := d.Readdirnames(0)
if err != nil {