Skip to content

Commit 960b926

Browse files
committed
fixed that the path may not be created correctly
1 parent eab2b66 commit 960b926

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

Account/SaveManager.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@
77
class SaveManager:
88
def __init__(self, username: str, basepath: str = PATH_SAVE):
99
self.filepath = os.path.join(basepath, f"{username}.json")
10-
if not os.path.exists(basepath): os.mkdir(basepath)
10+
if not os.path.exists(basepath):
11+
try:
12+
os.makedirs(basepath, exist_ok=True)
13+
except Exception as e:
14+
raise e
1115
try:
1216
with open(self.filepath, mode="r", encoding="UTF-8") as file:
1317
self.data = json.load(file)

Account/SettingManager.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ class SettingManager(metaclass=Singleton):
88

99
def __init__(self):
1010
if not os.path.exists(PATH_SETTING):
11-
os.mkdir(PATH_SETTING)
11+
try:
12+
os.makedirs(PATH_SETTING, exist_ok=True)
13+
except Exception as e:
14+
raise e
1215
try:
1316
with open(os.path.join(PATH_SETTING, "global.json"), mode="r", encoding="UTF-8") as file:
1417
self.data = json.load(file)
@@ -55,4 +58,3 @@ def defaultLanguage(self) -> str: return self.data["DefaultLanguage"]
5558
def defaultLanguage(self, value):
5659
self.data["DefaultLanguage"] = value
5760
self._save()
58-

0 commit comments

Comments
 (0)