mirror of
https://github.com/idootop/mi-gpt.git
synced 2024-09-20 06:45:38 +00:00
chore: 优化 db 路径查找方式
This commit is contained in:
parent
86feece787
commit
1992317f10
|
@ -13,6 +13,7 @@
|
|||
- ✅ 登录凭证过期后自动刷新 token https://github.com/idootop/mi-gpt/issues/76
|
||||
- ✅ 优化网络请求错误重试策略(消息/播放状态轮询)
|
||||
- ✅ 移除 TTS 不发音字符(emoji)
|
||||
- ✅ 优化 db 路径查找方式
|
||||
|
||||
## 📚 文档
|
||||
|
||||
|
|
|
@ -111,7 +111,7 @@ class _BotConfig {
|
|||
}
|
||||
const bot = await UserCRUD.get(this.botIndex!.botId);
|
||||
if (!bot) {
|
||||
this._logger.error("find bot failed");
|
||||
this._logger.error("find bot failed. 请删除 .bot.json 文件后重试!");
|
||||
return undefined;
|
||||
}
|
||||
const master = await UserCRUD.get(this.botIndex!.masterId);
|
||||
|
|
|
@ -28,13 +28,17 @@ export function getSkipWithCursor(skip: number, cursorId: any) {
|
|||
}
|
||||
|
||||
export function getDBInfo() {
|
||||
const isExternal = exists("node_modules/mi-gpt/prisma");
|
||||
const dbPath = isExternal
|
||||
? "node_modules/mi-gpt/prisma/app.db"
|
||||
: "prisma/app.db";
|
||||
const schemaPath = isExternal ? "node_modules/mi-gpt" : ".";
|
||||
const withSchema = `--schema ${schemaPath}/prisma/schema.prisma`;
|
||||
return { dbPath, isExternal, withSchema };
|
||||
let rootDir = import.meta.url
|
||||
.replace("/dist/index.js", "")
|
||||
.replace("/dist/index.cjs", "")
|
||||
.replace("/src/services/db/index.ts", "")
|
||||
.replace("file:///", "");
|
||||
if (rootDir[1] !== ":") {
|
||||
rootDir = "/" + rootDir; // linux root path
|
||||
}
|
||||
const dbPath = rootDir + "/prisma/app.db";
|
||||
const withSchema = `--schema ${rootDir}/prisma/schema.prisma`;
|
||||
return { dbPath, withSchema };
|
||||
}
|
||||
|
||||
export async function initDB() {
|
||||
|
|
Loading…
Reference in New Issue
Block a user