fix: fix webinterface broken when manual scan
Local Docker Build (Dev) / build-dev (push) Successful in 4s

This commit is contained in:
2025-10-14 16:29:27 -04:00
parent 051f9d7173
commit f903606d3a
2 changed files with 15 additions and 1 deletions
+14
View File
@@ -4,6 +4,7 @@ FastAPI routes for NFOGuard - extracted from main nfoguard.py for modular archit
import os
import json
import requests
import asyncio
from pathlib import Path
from datetime import datetime, timezone
from fastapi import HTTPException, BackgroundTasks, Request
@@ -584,15 +585,22 @@ async def manual_scan(background_tasks: BackgroundTasks, path: Optional[str] = N
else:
# Full series processing - scan subdirectories
import re
tv_count = 0
for item in scan_path.iterdir():
if (item.is_dir() and
not item.name.lower().startswith('season') and
not re.match(r'^season\s+\d+$', item.name, re.IGNORECASE) and
nfo_manager.parse_imdb_from_path(item)):
tv_count += 1
try:
tv_processor.process_series(item)
except Exception as e:
print(f"ERROR: Failed processing TV series {item}: {e}")
# Yield control every 5 TV series to allow other requests
if tv_count % 5 == 0:
await asyncio.sleep(0.1) # 100ms yield to process other requests
print(f"INFO: Processed {tv_count} TV series, yielding to other requests...")
if scan_type in ["both", "movies"] and scan_path in config.movie_paths:
print(f"INFO: Scanning movies in: {scan_path}")
@@ -605,6 +613,12 @@ async def manual_scan(background_tasks: BackgroundTasks, path: Optional[str] = N
movie_processor.process_movie(item)
except Exception as e:
print(f"ERROR: Failed processing movie {item}: {e}")
# Yield control every 10 movies to allow other requests (webhooks, web interface)
if movie_count % 10 == 0:
await asyncio.sleep(0.1) # 100ms yield to process other requests
print(f"INFO: Processed {movie_count} movies, yielding to other requests...")
print(f"INFO: Completed movie scan: {movie_count} movies processed in {scan_path}")
background_tasks.add_task(run_scan)