mirror of
https://github.com/Mrs4s/go-cqhttp.git
synced 2025-05-05 11:33:48 +08:00
fix: close body
This commit is contained in:
parent
79aabf5bd7
commit
ee3e1bac76
@ -953,8 +953,9 @@ func (bot *CQBot) CQGetImage(file string) MSG {
|
|||||||
local := path.Join(global.CachePath, file+"."+path.Ext(msg["filename"].(string)))
|
local := path.Join(global.CachePath, file+"."+path.Ext(msg["filename"].(string)))
|
||||||
if !global.PathExists(local) {
|
if !global.PathExists(local) {
|
||||||
f, _ := os.OpenFile(local, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0o0644)
|
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)
|
_, _ = f.ReadFrom(body)
|
||||||
|
_ = body.Close()
|
||||||
}
|
}
|
||||||
f.Close()
|
f.Close()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user