From 9534fc42fc9eea250462e8213a773352e224d4a3 Mon Sep 17 00:00:00 2001 From: wdvxdr Date: Sat, 1 May 2021 23:24:00 +0800 Subject: [PATCH] fix: close after read the cache file --- coolq/cqcode.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/coolq/cqcode.go b/coolq/cqcode.go index 6b5f880..bcd091b 100644 --- a/coolq/cqcode.go +++ b/coolq/cqcode.go @@ -1172,14 +1172,10 @@ func (bot *CQBot) makeImageOrVideoElem(d map[string]string, video, group bool) ( return bot.makeImageOrVideoElem(map[string]string{"file": d["url"]}, false, group) } if exist { - file, err := os.Open(rawPath) - if err != nil { - return nil, err - } if path.Ext(rawPath) != ".image" && path.Ext(rawPath) != ".cqimg" { - return &LocalImageElement{Stream: file}, nil + return &LocalImageElement{File: rawPath}, nil } - b, err := ioutil.ReadAll(file) + b, err := os.ReadFile(rawPath) if err != nil { return nil, err }