From ee3e1bac76070b7675de9ee1f09a6ea753508bd7 Mon Sep 17 00:00:00 2001 From: wdvxdr Date: Fri, 16 Apr 2021 20:25:12 +0800 Subject: [PATCH] fix: close body --- coolq/api.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/coolq/api.go b/coolq/api.go index 97bf14e..1072fa6 100644 --- a/coolq/api.go +++ b/coolq/api.go @@ -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() }