Skip to content

Commit d7c7323

Browse files
committed
prefsstore: Fix the broken path access for the prefs
This walks through the parent paths and tries to `mkdir` on them in turn if they don't exist. Closes: #30
1 parent 9ba9349 commit d7c7323

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

g13gui/model/prefsstore.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import json
22
import threading
33

4+
from pathlib import Path
5+
46
from g13gui.model.prefs import Preferences
57
from g13gui.common import PROFILES_CONFIG_PATH
68

@@ -23,6 +25,13 @@ def storePrefs(prefs):
2325
with PreferencesStore.SaveLock:
2426
prefsDict = prefs.saveToDict()
2527

28+
# make each directory in turn
29+
partialpath = Path()
30+
for part in PROFILES_CONFIG_PATH.parent.parts:
31+
partialpath = partialpath / part
32+
if not partialpath.exists():
33+
partialpath.mkdir()
34+
2635
with open(PROFILES_CONFIG_PATH, 'w') as f:
2736
f.write(json.dumps(prefsDict, default=str))
2837
f.flush()

0 commit comments

Comments
 (0)