Skip to content

Commit

Permalink
修复当关闭缓存功能时异常报错的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
rroy233 committed Feb 3, 2024
1 parent 49163d5 commit 8e54427
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
6 changes: 4 additions & 2 deletions handler/DownloadStickerSetQuery.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,10 @@ func downloadWorker(ctx context.Context, queue chan tgbotapi.Sticker, task *down
atomic.AddInt32(&task.failed, 1)
continue
}
if _, err := db.CacheSticker(sticker, convertTask.OutputFilePath); err != nil {
logger.Error.Printf("DownloadStickerSetQuery[%d/%d]-failed to Save Cache:%s,%s", i, sum, err.Error(), stickerInfo)
if config.Get().Cache.Enabled == true {
if _, err := db.CacheSticker(sticker, convertTask.OutputFilePath); err != nil {
logger.Error.Printf("DownloadStickerSetQuery[%d/%d]-failed to Save Cache:%s,%s", i, sum, err.Error(), stickerInfo)
}
}
}
atomic.AddInt32(&task.finished, 1)
Expand Down
16 changes: 9 additions & 7 deletions handler/StickersMessage.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,15 @@ func StickerMessage(update tgbotapi.Update) {
}

//CacheSticker
cacheItem, err = db.CacheSticker(*update.Message.Sticker, convertTask.OutputFilePath)
if err != nil {
logger.Error.Println(userInfo+"CacheSticker Error ", err)
} else {
cacheItem.ConvertedFileID = sentMsg.Document.FileID
if err := cacheItem.Update(); err != nil {
logger.Error.Println(userInfo+"failed to update cache:", err)
if config.Get().Cache.Enabled == true {
cacheItem, err = db.CacheSticker(*update.Message.Sticker, convertTask.OutputFilePath)
if err != nil {
logger.Error.Println(userInfo+"CacheSticker Error ", err)
} else {
cacheItem.ConvertedFileID = sentMsg.Document.FileID
if err := cacheItem.Update(); err != nil {
logger.Error.Println(userInfo+"failed to update cache:", err)
}
}
}
utils.RemoveFile(outPath)
Expand Down

0 comments on commit 8e54427

Please sign in to comment.