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