From 9470ca6bc503d719ea8fccd4a1bb98a9b318197f Mon Sep 17 00:00:00 2001 From: Raven95676 Date: Sun, 13 Apr 2025 11:36:06 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=B8=8D=E5=AD=98=E5=9C=A8=E7=9A=84=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- astrbot/core/utils/shared_preferences.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/astrbot/core/utils/shared_preferences.py b/astrbot/core/utils/shared_preferences.py index fc0bf7434..33a681419 100644 --- a/astrbot/core/utils/shared_preferences.py +++ b/astrbot/core/utils/shared_preferences.py @@ -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):