MCPcopy Create free account
hub / github.com/Louisym/MiniCC / _read_entries

Method _read_entries

mini_claude_code/storage.py:159–178  ·  view source on GitHub ↗

逐行解析 JSONL。 崩溃安全: 跳过空行和解析失败的行。 CC 的保证: 最多丢失最后一行(写入被中断的行)。

(path: Path)

Source from the content-addressed store, hash-verified

157
158 @staticmethod
159 def _read_entries(path: Path) -> list[StorageEntry]:
160 """逐行解析 JSONL。
161
162 崩溃安全: 跳过空行和解析失败的行。
163 CC 的保证: 最多丢失最后一行(写入被中断的行)。
164 """
165 if not path.exists():
166 return []
167
168 entries: list[StorageEntry] = []
169 with open(path, "r", encoding="utf-8") as f:
170 for line in f:
171 line = line.strip()
172 if not line:
173 continue
174 try:
175 entries.append(StorageEntry.model_validate_json(line))
176 except Exception:
177 continue # 跳过损坏的行
178 return entries
179
180 @staticmethod
181 def _rebuild_chain(entries: list[StorageEntry]) -> list[StorageEntry]:

Callers 2

load_sessionMethod · 0.95
detect_interruptionMethod · 0.95

Calls 1

appendMethod · 0.80

Tested by

no test coverage detected