Merge pull request #4033 from h3poteto/iss-4032

refs #4032 Create db directory if does not exist
This commit is contained in:
AkiraFukushima 2023-01-21 18:53:03 +09:00 committed by GitHub
commit 2508bed591
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 3 deletions

View File

@ -16,7 +16,7 @@ import {
Notification,
NotificationConstructorOptions
} from 'electron'
import fs from 'fs'
import crypto from 'crypto'
import log from 'electron-log'
import windowStateKeeper from 'electron-window-state'
@ -116,11 +116,16 @@ const splashURL =
const userData = app.getPath('userData')
const appPath = app.getPath('exe')
const dbDir = path.join(userData, '/db')
const databasePath = process.env.NODE_ENV === 'production' ? userData + '/db/whalebird.db' : 'whalebird.db'
if (!fs.existsSync(dbDir) || !fs.lstatSync(dbDir).isDirectory()) {
fs.mkdirSync(dbDir, { recursive: true })
}
const databasePath = path.join(dbDir, 'whalebird.db')
const db = newDB(databasePath)
const preferencesDBPath = process.env.NODE_ENV === 'production' ? userData + './db/preferences.json' : 'preferences.json'
const preferencesDBPath = path.join(dbDir, 'preferences.json')
const soundBasePath =
process.env.NODE_ENV === 'development' ? path.join(__dirname, '../../build/sounds/') : path.join(process.resourcesPath!, 'build/sounds/')