fix: mark initial scan as completed after setup endpoint sync

- Add mark_initial_scan_completed() call to /api/auth/setup endpoint
- Ensures initial_scan_completed flag is set to True after first sync
- Prevents duplicate folder scans on subsequent application startups
- Include error handling to prevent setup failure if marking fails
This commit is contained in:
2026-01-21 20:24:16 +01:00
parent 61c86dc698
commit 8e8487b7b7

View File

@@ -51,10 +51,10 @@ async def setup_auth(req: SetupRequest):
except Exception:
# If config doesn't exist, create default
from src.server.models.config import (
SchedulerConfig,
LoggingConfig,
BackupConfig,
LoggingConfig,
NFOConfig,
SchedulerConfig,
)
config = AppConfig()
@@ -122,6 +122,10 @@ async def setup_auth(req: SetupRequest):
try:
import structlog
from src.server.database.connection import get_db_session
from src.server.database.system_settings_service import (
SystemSettingsService,
)
from src.server.services.anime_service import (
sync_series_from_data_files,
)
@@ -133,6 +137,19 @@ async def setup_auth(req: SetupRequest):
"Setup complete: synced series from data files",
count=sync_count
)
# Mark initial scan as completed
try:
async with get_db_session() as db:
await SystemSettingsService.mark_initial_scan_completed(
db
)
logger.info("Marked initial scan as completed")
except Exception as mark_error:
logger.warning(
"Failed to mark initial scan as completed",
error=str(mark_error)
)
except Exception as e:
# Log but don't fail setup if sync fails
import structlog