From 489784104e9ea76ad1b3941b2b9cc9fc68293a85 Mon Sep 17 00:00:00 2001 From: Raven95676 Date: Sat, 12 Apr 2025 19:31:45 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20shared=5Fpreferences=E5=8A=A0=E8=BD=BD?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E6=97=B6=E8=87=AA=E5=8A=A8=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E6=97=A0=E6=95=88=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- astrbot/core/utils/shared_preferences.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/astrbot/core/utils/shared_preferences.py b/astrbot/core/utils/shared_preferences.py index b11987322..fc0bf7434 100644 --- a/astrbot/core/utils/shared_preferences.py +++ b/astrbot/core/utils/shared_preferences.py @@ -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):