1
0
mirror of https://github.com/Mrs4s/go-cqhttp.git synced 2025-07-06 14:23:24 +00:00

fix: close body

This commit is contained in:
wdvxdr
2021-04-16 20:25:12 +08:00
parent 79aabf5bd7
commit ee3e1bac76

View File

@ -953,8 +953,9 @@ func (bot *CQBot) CQGetImage(file string) MSG {
local := path.Join(global.CachePath, file+"."+path.Ext(msg["filename"].(string)))
if !global.PathExists(local) {
f, _ := os.OpenFile(local, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0o0644)
if body, err := global.HTTPGetReadCloser(msg["url"].(string)); err != nil {
if body, err := global.HTTPGetReadCloser(msg["url"].(string)); err == nil {
_, _ = f.ReadFrom(body)
_ = body.Close()
}
f.Close()
}