fix(session): use logger.exception and move import to top

This commit is contained in:
Re-bin
2026-02-22 15:40:17 +00:00
parent b8a06f8d19
commit 71de1899e6

View File

@@ -1,6 +1,7 @@
"""Session management for conversation history.""" """Session management for conversation history."""
import json import json
import shutil
from pathlib import Path from pathlib import Path
from dataclasses import dataclass, field from dataclasses import dataclass, field
from datetime import datetime from datetime import datetime
@@ -109,11 +110,10 @@ class SessionManager:
legacy_path = self._get_legacy_session_path(key) legacy_path = self._get_legacy_session_path(key)
if legacy_path.exists(): if legacy_path.exists():
try: try:
import shutil
shutil.move(str(legacy_path), str(path)) shutil.move(str(legacy_path), str(path))
logger.info("Migrated session {} from legacy path", key) logger.info("Migrated session {} from legacy path", key)
except Exception as e: except Exception:
logger.warning("Failed to migrate session {}: {}", key, e) logger.exception("Failed to migrate session {}", key)
if not path.exists(): if not path.exists():
return None return None