fix(session): handle errors in legacy session migration
shutil.move() in _load() can fail due to permissions, disk full, or concurrent access. Without error handling, the exception propagates up and prevents the session from loading entirely. Wrap in try/except so migration failures are logged as warnings and the session falls back to loading from the legacy path on next attempt. Fixes #863
This commit is contained in:
@@ -108,9 +108,12 @@ class SessionManager:
|
||||
if not path.exists():
|
||||
legacy_path = self._get_legacy_session_path(key)
|
||||
if legacy_path.exists():
|
||||
import shutil
|
||||
shutil.move(str(legacy_path), str(path))
|
||||
logger.info("Migrated session {} from legacy path", key)
|
||||
try:
|
||||
import shutil
|
||||
shutil.move(str(legacy_path), str(path))
|
||||
logger.info("Migrated session {} from legacy path", key)
|
||||
except Exception as e:
|
||||
logger.warning("Failed to migrate session {}: {}", key, e)
|
||||
|
||||
if not path.exists():
|
||||
return None
|
||||
|
||||
Reference in New Issue
Block a user