fix: 更新图片下载逻辑,移除临时文件删除操作并直接使用封面图片路径

This commit is contained in:
lixiangwuxian 2025-04-12 21:17:53 +08:00
parent 7ba0f74b49
commit 6ddb3574d0
2 changed files with 2 additions and 7 deletions

View File

@ -2,7 +2,6 @@ package beatleader
import (
"log"
"os"
"strconv"
"sync"
@ -178,13 +177,12 @@ func getMyRecentScore(msg model.Message) (reply *model.Reply) {
wg.Add(1)
go func(songHash string) {
defer wg.Done()
filePath, err := util.DownloadFile(coverImageMap[songHash], "/tmp/qqbot", true)
filePath, err := util.DownloadFile(coverImageMap[songHash], constants.TempDir, true)
if err != nil {
log.Printf("下载图片失败: %v", err)
return
}
newPath, err := util.ResizeImageByMaxHeight(filePath, 20)
os.Remove(filePath)
if err != nil {
log.Printf("缩放图片失败: %v", err)
}
@ -196,7 +194,7 @@ func getMyRecentScore(msg model.Message) (reply *model.Reply) {
imageMsg := message.ImageMessage{
Type: "image",
Data: message.ImageMessageData{
File: util.GetResizedIamgePathByOrgPath(util.GenTempFilePath(record.SongHash + ".jpeg")),
File: coverImageMap[record.SongHash],
},
}
scoreMsg += imageMsg.ToCQString() + record.ToString() + "\n"

View File

@ -210,9 +210,6 @@ func getMyRecentScore(msg model.Message) (reply *model.Reply) {
go func(songHash string) {
defer wg.Done()
//文件存在则跳过
// if _, err := os.Stat(util.GetResizedIamgePathByOrgPath(util.GenTempFilePath(songHash + ".jpeg"))); err == nil {
// return
// }
filePath, err := util.DownloadFile(coverImageMap[songHash], constants.TempDir, true)
if err != nil {
log.Printf("下载图片失败: %v", err)