From 744a282d75d8da1e24ffcd9e18e34dd525d5be0e Mon Sep 17 00:00:00 2001
From: admin <admin@example.com>
Date: 星期三, 15 一月 2025 15:45:34 +0800
Subject: [PATCH] 缓存目录修改

---
 strategy/kpl_api.py |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/strategy/kpl_api.py b/strategy/kpl_api.py
index f652ce8..ac413f9 100644
--- a/strategy/kpl_api.py
+++ b/strategy/kpl_api.py
@@ -388,8 +388,11 @@
     # 娓呯悊澶氫綑鏁版嵁鍑芥暟
     def check_and_remove_oldest_entry(self, max_entries):
         # 璇诲彇鎵�鏈夎骞惰В鏋愪负 JSON 瀵硅薄鍒楄〃
-        with open(self.file_path, 'r', encoding='utf-8') as file:
-            lines = [json.loads(line.strip()) for line in file if line.strip()]
+        if os.path.exists(self.file_path):
+            with open(self.file_path, 'r', encoding='utf-8') as file:
+                lines = [json.loads(line.strip()) for line in file if line.strip()]
+        else:
+            lines = []
 
             # 濡傛灉琛屾暟瓒呰繃闄愬埗锛岀Щ闄ゆ渶鏃╃殑涓�浜涜
         if len(lines) >= max_entries:

--
Gitblit v1.8.0