mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-04-12 14:13:39 +00:00
Merge PR #958: fix(session): handle errors in legacy session migration
This commit is contained in:
commit
598f7dafd1
@ -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
|
||||||
@ -108,9 +109,11 @@ class SessionManager:
|
|||||||
if not path.exists():
|
if not path.exists():
|
||||||
legacy_path = self._get_legacy_session_path(key)
|
legacy_path = self._get_legacy_session_path(key)
|
||||||
if legacy_path.exists():
|
if legacy_path.exists():
|
||||||
import shutil
|
try:
|
||||||
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:
|
||||||
|
logger.exception("Failed to migrate session {}", key)
|
||||||
|
|
||||||
if not path.exists():
|
if not path.exists():
|
||||||
return None
|
return None
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user