Skip to content

Commit 0b2059c

Browse files
committed
feat: make sure entity dir exists
1 parent 57e0af3 commit 0b2059c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/app/persistence/storage.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { existsSync, promises as fs } from 'fs';
33
import path from 'path';
44

55
export function getUserDir() {
6-
return path.join(app.getPath('appData'), 'entities');
6+
return path.join(app.getPath('userData'), 'entities');
77
}
88

99
export function fromJson<T>(content: string): T {
@@ -23,6 +23,11 @@ export function saveFile<T>(filename: string, data: T) {
2323
}
2424

2525
export function createFileIfNotExisting<T>(filename: string, data: T) {
26+
const dirExists = existsSync(getUserDir());
27+
if (!dirExists) {
28+
fs.mkdir(getUserDir());
29+
}
30+
2631
const exists = existsSync(path.join(getUserDir(), filename));
2732
if (!exists) {
2833
saveFile(filename, data);

0 commit comments

Comments
 (0)