Skip to content

Commit

Permalink
修复部分临时文件未清理的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
rroy233 committed Jun 20, 2024
1 parent 895d0b9 commit ebc58d8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion handler/StickersMessage.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func StickerMessage(update tgbotapi.Update) {
err = convertTask.Run(ctx)
cancel()
if err != nil {
logger.Error.Println(userInfo+"failed to convert:", err)
logger.Error.Println(userInfo+"failed to convert:", err, convertTask.OutputFilePath)
utils.EditMsgText(update.Message.Chat.ID, msg.MessageID, languages.Get(&update).BotMsg.ErrConvertFailed)
return
}
Expand Down
6 changes: 6 additions & 0 deletions utils/convertTask.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ func (task *ConvertTask) Run(ctx context.Context) error {
task.InputFilePath = task.InputFilePath + ".json"
//handle it to rlottie
cmd = exec.CommandContext(ctx, rlottieExcutablePath, strings.Split(fmt.Sprintf("%s 200x200", task.InputFilePath), " ")...)
//remember to delete xxx.tgs.json
defer func() {
if err := os.Remove(task.InputFilePath); err != nil {
logger.Warn.Println("failed to remove", task.InputFilePath)
}
}()
} else {
cmd = exec.CommandContext(ctx, ffmpegExecutablePath, strings.Split(fmt.Sprintf("-y -i %s -vf scale=-1:-1 -r 20 %s", task.InputFilePath, task.OutputFilePath), " ")...)
}
Expand Down

0 comments on commit ebc58d8

Please sign in to comment.