fix(middleware): prevent premature redirect to /login during loading
Users were incorrectly redirected to /login during the initial loading phase before the loading was actually complete. Added loading_started and loading_complete flags to properly track the initialization state so the setup redirect middleware knows when it's safe to redirect.
This commit is contained in:
@@ -383,6 +383,16 @@ async def perform_initial_setup(progress_service=None):
|
||||
# Mark the initial scan as completed
|
||||
await _mark_initial_scan_completed()
|
||||
|
||||
# Mark loading as complete in config (used by middleware to allow redirect to /login)
|
||||
try:
|
||||
from src.server.services.config_service import get_config_service
|
||||
config_svc = get_config_service()
|
||||
init_config = config_svc.load_config()
|
||||
init_config.other['loading_complete'] = True
|
||||
config_svc.save_config(init_config, create_backup=False)
|
||||
except Exception as e:
|
||||
logger.warning("Failed to save loading_complete flag: %s", e)
|
||||
|
||||
# Load series into memory from database
|
||||
await _load_series_into_memory(progress_service)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user