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:
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)
|
return bot.makeImageOrVideoElem(map[string]string{"file": d["url"]}, false, group)
|
||||||
}
|
}
|
||||||
if exist {
|
if exist {
|
||||||
file, err := os.Open(rawPath)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if path.Ext(rawPath) != ".image" && path.Ext(rawPath) != ".cqimg" {
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user