Merge pull request #1247 from Raven95676/shared_preferences

perf: shared_preferences加载失败时自动删除无效文件
This commit is contained in:
Soulter
2025-04-12 20:04:19 +08:00
committed by GitHub
+3 -1
View File
@@ -8,9 +8,11 @@ class SharedPreferences:
self._data = self._load_preferences()
def _load_preferences(self):
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):