Merge pull request #1261 from Raven95676/master

fix: 修复文件不存在的情况
This commit is contained in:
渡鸦95676
2025-04-13 11:40:33 +08:00
committed by GitHub
+6 -5
View File
@@ -8,11 +8,12 @@ class SharedPreferences:
self._data = self._load_preferences()
def _load_preferences(self):
try:
with open(self.path, "r") as f:
return json.load(f)
except json.JSONDecodeError:
os.remove(self.path)
if os.path.exists(self.path):
try:
with open(self.path, "r") as f:
return json.load(f)
except json.JSONDecodeError:
os.remove(self.path)
return {}
def _save_preferences(self):