1
0
mirror of https://github.com/Mrs4s/go-cqhttp.git synced 2025-05-06 03:53:50 +08:00

fix: close after read the cache file

This commit is contained in:
wdvxdr 2021-05-01 23:24:00 +08:00
parent 80827b8614
commit 9534fc42fc
No known key found for this signature in database
GPG Key ID: 55FF1414A69CEBA6

View File

@ -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
}