fix: 必须清理并回收

This commit is contained in:
手瓜一十雪 2025-02-03 11:40:58 +08:00
parent 3a27f37686
commit b32d4b618c

View File

@ -941,15 +941,18 @@ export class OneBotMsgApi {
const timeout = 10000 + (totalSize / 1024 / 256 * 1000); const timeout = 10000 + (totalSize / 1024 / 256 * 1000);
try {
const returnMsg = await this.core.apis.MsgApi.sendMsg(peer, sendElements, timeout); const returnMsg = await this.core.apis.MsgApi.sendMsg(peer, sendElements, timeout);
if (!returnMsg) throw new Error('发送消息失败'); if (!returnMsg) throw new Error('发送消息失败');
returnMsg.id = MessageUnique.createUniqueMsgId({ returnMsg.id = MessageUnique.createUniqueMsgId({
chatType: peer.chatType, chatType: peer.chatType,
guildId: '', guildId: '',
peerUid: peer.peerUid, peerUid: peer.peerUid,
}, returnMsg.msgId); }, returnMsg.msgId);
return returnMsg;
} catch (error) {
throw new Error((error as Error).message);
} finally {
setTimeout(async () => { setTimeout(async () => {
const deletePromises = deleteAfterSentFiles.map(async file => { const deletePromises = deleteAfterSentFiles.map(async file => {
try { try {
@ -962,8 +965,7 @@ export class OneBotMsgApi {
}); });
await Promise.all(deletePromises); await Promise.all(deletePromises);
}, 60000); }, 60000);
}
return returnMsg;
} }
private async handleOb11FileLikeMessage( private async handleOb11FileLikeMessage(