Skip to content

Commit d20bd9a

Browse files
fix(db): ensure directory exists before accessing the db (#628)
1 parent 541eb94 commit d20bd9a

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/main/db/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ export function useDB() {
4444
return db
4545

4646
const dbPath = `${store.preferences.get('storagePath')}/${DB_NAME}`
47+
const dbDir = path.dirname(dbPath)
48+
49+
if (!fs.existsSync(dbDir)) {
50+
fs.mkdirSync(dbDir, { recursive: true })
51+
}
4752

4853
if (fs.existsSync(dbPath) && !isSqliteFile(dbPath)) {
4954
const backupPath = `${dbPath}.old`

0 commit comments

Comments
 (0)