mirror of
https://github.com/Mrs4s/go-cqhttp.git
synced 2025-05-05 19:43:49 +08:00
fix: close after read the cache file
This commit is contained in:
parent
80827b8614
commit
9534fc42fc
@ -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
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user