mirror of
https://github.com/geekgeekrun/geekgeekrun.git
synced 2026-05-11 18:09:50 +08:00
migrate db file to runtimeFolder
This commit is contained in:
@@ -141,3 +141,7 @@ export const writeStorageFile = async (fileName, content) => {
|
||||
fileContent
|
||||
)
|
||||
}
|
||||
|
||||
export const getPublicDbFilePath = () => {
|
||||
return path.join(storageFilePath, 'public.db')
|
||||
}
|
||||
@@ -8,7 +8,7 @@ import fs from 'node:fs'
|
||||
import path from 'node:path'
|
||||
import { get__dirname } from '@geekgeekrun/utils/legacy-path.mjs';
|
||||
import JSON5 from 'json5'
|
||||
import { readConfigFile, readStorageFile } from '@geekgeekrun/geek-auto-start-chat-with-boss/runtime-file-utils.mjs'
|
||||
import { readConfigFile, readStorageFile, getPublicDbFilePath } from '@geekgeekrun/geek-auto-start-chat-with-boss/runtime-file-utils.mjs'
|
||||
import { sleep } from '@geekgeekrun/utils/sleep.mjs'
|
||||
import {
|
||||
AUTO_CHAT_ERROR_EXIT_CODE
|
||||
@@ -37,7 +37,7 @@ const { groupRobotAccessToken: dingTalkAccessToken } = readConfigFile('dingtalk.
|
||||
|
||||
const initPlugins = (hooks) => {
|
||||
new DingtalkPlugin(dingTalkAccessToken).apply(hooks)
|
||||
new SqlitePlugin().apply(hooks)
|
||||
new SqlitePlugin(getPublicDbFilePath()).apply(hooks)
|
||||
}
|
||||
|
||||
const main = async () => {
|
||||
|
||||
@@ -12,13 +12,13 @@ import { BossActiveStatusRecord } from "./entity/BossActiveStatusRecord";
|
||||
import { UserInfo } from "./entity/UserInfo";
|
||||
import { parseCompanyScale, parseSalary } from "./utils/parser";
|
||||
|
||||
async function initDb() {
|
||||
async function initDb(dbFilePath) {
|
||||
const appDataSource = new DataSource({
|
||||
type: "sqlite",
|
||||
synchronize: true,
|
||||
logging: true,
|
||||
logger: "simple-console",
|
||||
database: "database.sqlite",
|
||||
database: dbFilePath,
|
||||
entities: [
|
||||
ChatStartupLog,
|
||||
BossInfo,
|
||||
@@ -37,8 +37,8 @@ async function initDb() {
|
||||
export default class SqlitePlugin {
|
||||
initPromise: Promise<DataSource>;
|
||||
|
||||
constructor() {
|
||||
this.initPromise = initDb();
|
||||
constructor(dbFilePath) {
|
||||
this.initPromise = initDb(dbFilePath);
|
||||
}
|
||||
|
||||
userInfo = null
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
import DingtalkPlugin from '@geekgeekrun/dingtalk-plugin/index.mjs'
|
||||
import { app } from 'electron'
|
||||
import { SyncHook, AsyncSeriesHook } from 'tapable'
|
||||
import { readConfigFile } from '@geekgeekrun/geek-auto-start-chat-with-boss/runtime-file-utils.mjs'
|
||||
import {
|
||||
readConfigFile,
|
||||
getPublicDbFilePath
|
||||
} from '@geekgeekrun/geek-auto-start-chat-with-boss/runtime-file-utils.mjs'
|
||||
|
||||
import * as fs from 'fs'
|
||||
import { pipeWriteRegardlessError } from '../utils/pipe'
|
||||
import { getAnyAvailablePuppeteerExecutable } from '../CHECK_AND_DOWNLOAD_DEPENDENCIES/utils/puppeteer-executable'
|
||||
@@ -15,7 +19,7 @@ const { groupRobotAccessToken: dingTalkAccessToken } = readConfigFile('dingtalk.
|
||||
|
||||
const initPlugins = (hooks) => {
|
||||
new DingtalkPlugin(dingTalkAccessToken).apply(hooks)
|
||||
new SqlitePlugin().apply(hooks)
|
||||
new SqlitePlugin(getPublicDbFilePath()).apply(hooks)
|
||||
}
|
||||
|
||||
let isParentProcessDisconnect = false
|
||||
|
||||
Reference in New Issue
Block a user