From e1d47f55bff42170b46a22e622e1ea6080714169 Mon Sep 17 00:00:00 2001 From: linyuchen Date: Wed, 6 Mar 2024 22:55:33 +0800 Subject: [PATCH] fix: hotfix db initialize failed --- manifest.json | 4 ++-- src/common/db.ts | 19 ++++++++++++------- src/main/main.ts | 2 +- src/version.ts | 2 +- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/manifest.json b/manifest.json index 7db71be..7f1908f 100644 --- a/manifest.json +++ b/manifest.json @@ -1,10 +1,10 @@ { "manifest_version": 4, "type": "extension", - "name": "LLOneBot v3.13.0", + "name": "LLOneBot v3.13.1", "slug": "LLOneBot", "description": "LiteLoaderQQNT的OneBotApi", - "version": "3.13.0", + "version": "3.13.1", "thumbnail": "./icon.png", "authors": [ { diff --git a/src/common/db.ts b/src/common/db.ts index 4c1509f..2cdbb98 100644 --- a/src/common/db.ts +++ b/src/common/db.ts @@ -1,7 +1,7 @@ // import {DATA_DIR} from "./utils"; import {Level} from "level"; import {RawMessage} from "../ntqqapi/types"; -import {DATA_DIR} from "./utils"; +import {DATA_DIR, log} from "./utils"; import {selfInfo} from "./data"; @@ -93,14 +93,14 @@ class DBUtil { // 有则更新,无则添加 const longIdKey = this.DB_KEY_PREFIX_MSG_ID + msg.msgId let existMsg = this.cache[longIdKey] - if (!existMsg){ + if (!existMsg) { try { existMsg = await this.getMsgByLongId(msg.msgId) - }catch (e) { + } catch (e) { } } - if (existMsg){ + if (existMsg) { this.updateMsg(msg).then() return existMsg.msgShortId } @@ -108,10 +108,15 @@ class DBUtil { const shortMsgId = await this.genMsgShortId(); const shortIdKey = this.DB_KEY_PREFIX_MSG_SHORT_ID + shortMsgId; const seqIdKey = this.DB_KEY_PREFIX_MSG_SEQ_ID + msg.msgSeq; - await this.db.put(shortIdKey, msg.msgId); msg.msgShortId = shortMsgId; - await this.db.put(longIdKey, JSON.stringify(msg)); - await this.db.put(seqIdKey, msg.msgId); + try { + await this.db.put(shortIdKey, msg.msgId); + await this.db.put(longIdKey, JSON.stringify(msg)); + await this.db.put(seqIdKey, msg.msgId); + + } catch (e) { + log("addMsg db error", e.stack.toString()); + } this.cache[seqIdKey] = this.cache[shortIdKey] = this.cache[longIdKey] = msg; return shortMsgId } diff --git a/src/main/main.ts b/src/main/main.ts index c0e49a0..56f4e02 100644 --- a/src/main/main.ts +++ b/src/main/main.ts @@ -177,7 +177,7 @@ function onLoad() { try { await postReceiveMsg(payload.msgList); } catch (e) { - log("report message error: ", e.toString()); + log("report message error: ", e.stack.toString()); } }) registerReceiveHook<{ msgList: Array }>(ReceiveCmd.UPDATE_MSG, async (payload) => { diff --git a/src/version.ts b/src/version.ts index edd1843..249bb3e 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export const version = "3.13.0" \ No newline at end of file +export const version = "3.13.1" \ No newline at end of file