From 14ae2a205ca77934509c2259ba57c3a25a9d67d4 Mon Sep 17 00:00:00 2001 From: SBCrumb Date: Sun, 26 Oct 2025 13:22:11 -0400 Subject: [PATCH] updates: debugs --- api/routes.py | 41 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/api/routes.py b/api/routes.py index 72ac1b7..38cdbfa 100644 --- a/api/routes.py +++ b/api/routes.py @@ -2291,6 +2291,9 @@ def register_routes(app, dependencies: dict): print("🔧 Starting NFO repair scan from core container") + import time + scan_start_time = time.time() + missing_items = { "episodes": [], "movies": [] @@ -2313,8 +2316,25 @@ def register_routes(app, dependencies: dict): episodes = [dict(row) for row in cursor.fetchall()] print(f"📊 Found {len(episodes)} episodes in database") - + + processed_count = 0 for episode in episodes: + processed_count += 1 + + # Progress logging every 1000 items + if processed_count % 1000 == 0: + elapsed = time.time() - scan_start_time + print(f"📊 Progress: {processed_count}/{len(episodes)} episodes processed in {elapsed:.1f}s, {len(missing_items['episodes'])} missing found so far") + + # Time-based exit (max 3 minutes for episodes) + if time.time() - scan_start_time > 180: + print(f"⏰ Episode scan timeout after 3 minutes - processed {processed_count}/{len(episodes)} episodes") + break + + # Early exit if we find too many missing items (performance safety) + if len(missing_items['episodes']) > 1000: + print(f"⚠️ Found {len(missing_items['episodes'])} missing episodes - stopping scan to prevent performance issues") + break # Build NFO path using series path series_name = os.path.basename(episode["series_path"]) @@ -2398,8 +2418,25 @@ def register_routes(app, dependencies: dict): movies = [dict(row) for row in cursor.fetchall()] print(f"📊 Found {len(movies)} movies in database") - + + processed_count = 0 for movie in movies: + processed_count += 1 + + # Progress logging every 500 items + if processed_count % 500 == 0: + elapsed = time.time() - scan_start_time + print(f"📊 Progress: {processed_count}/{len(movies)} movies processed in {elapsed:.1f}s, {len(missing_items['movies'])} missing found so far") + + # Time-based exit (max 5 minutes total) + if time.time() - scan_start_time > 300: + print(f"⏰ Total scan timeout after 5 minutes - processed {processed_count}/{len(movies)} movies") + break + + # Early exit if we find too many missing items (performance safety) + if len(missing_items['movies']) > 500: + print(f"⚠️ Found {len(missing_items['movies'])} missing movies - stopping scan to prevent performance issues") + break # Build NFO path using movie path movie_title = os.path.basename(movie["path"])