mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-07-19 12:03:37 +00:00
fix: 必须清理并回收
This commit is contained in:
@@ -941,29 +941,31 @@ export class OneBotMsgApi {
|
|||||||
|
|
||||||
const timeout = 10000 + (totalSize / 1024 / 256 * 1000);
|
const timeout = 10000 + (totalSize / 1024 / 256 * 1000);
|
||||||
|
|
||||||
const returnMsg = await this.core.apis.MsgApi.sendMsg(peer, sendElements, timeout);
|
try {
|
||||||
if (!returnMsg) throw new Error('发送消息失败');
|
const returnMsg = await this.core.apis.MsgApi.sendMsg(peer, sendElements, timeout);
|
||||||
|
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;
|
||||||
setTimeout(async () => {
|
} catch (error) {
|
||||||
const deletePromises = deleteAfterSentFiles.map(async file => {
|
throw new Error((error as Error).message);
|
||||||
try {
|
} finally {
|
||||||
if (await fsPromise.access(file, constants.W_OK).then(() => true).catch(() => false)) {
|
setTimeout(async () => {
|
||||||
await fsPromise.unlink(file);
|
const deletePromises = deleteAfterSentFiles.map(async file => {
|
||||||
|
try {
|
||||||
|
if (await fsPromise.access(file, constants.W_OK).then(() => true).catch(() => false)) {
|
||||||
|
await fsPromise.unlink(file);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
this.core.context.logger.logError('发送消息删除文件失败', e);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
});
|
||||||
this.core.context.logger.logError('发送消息删除文件失败', e);
|
await Promise.all(deletePromises);
|
||||||
}
|
}, 60000);
|
||||||
});
|
}
|
||||||
await Promise.all(deletePromises);
|
|
||||||
}, 60000);
|
|
||||||
|
|
||||||
return returnMsg;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async handleOb11FileLikeMessage(
|
private async handleOb11FileLikeMessage(
|
||||||
|
Reference in New Issue
Block a user