Commit c87bb53c authored by Kantz's avatar Kantz
Browse files

fehler mit fehlendem Context-Sheet gefixed

parent d1b0dbde
......@@ -23,10 +23,11 @@ def _latest_filename_pattern(chat_id: str) -> str:
return os.path.join(_LOG_DIR, f"*_{chat_id}_latest.json")
def _resolve_latest_path(chat_id: str) -> str:
def _resolve_latest_path(chat_id: str) -> str | None:
matches = glob(_latest_filename_pattern(chat_id))
if matches:
return max(matches, key=os.path.getmtime)
return None
def _utc_now() -> str:
......@@ -73,7 +74,7 @@ def load_sheet(chat_id: str) -> dict[str, Any] | None:
return _CACHE[chat_id]
latest_path = _resolve_latest_path(chat_id)
if os.path.exists(latest_path):
if latest_path and os.path.exists(latest_path):
with open(latest_path, "r", encoding="utf-8") as file_handle:
sheet = json.load(file_handle)
with _LOCK:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment