fixes: web interface shutdown
Local Docker Build (Dev) / build-dev (push) Successful in 4s

This commit is contained in:
2025-10-20 08:30:55 -04:00
parent eb9bfbf82e
commit 3c4e47b08e
5 changed files with 91 additions and 9 deletions
+53 -2
View File
@@ -53,6 +53,48 @@ class TVProcessor:
path_mapper=self.path_mapper
)
def should_skip_series_fast(self, imdb_id: str, series_name: str = "") -> Tuple[bool, str, int]:
"""
Fast preliminary check to skip series without filesystem scan
Args:
imdb_id: Series IMDb ID
series_name: Series name for logging
Returns:
(should_skip: bool, reason: str, episodes_in_db: int)
"""
try:
with self.db.get_connection() as conn:
cursor = conn.cursor()
# Check if we have complete episodes in database
cursor.execute("""
SELECT
COUNT(*) as total_in_db,
COUNT(CASE WHEN dateadded IS NOT NULL AND source IS NOT NULL AND source != 'unknown' AND source != 'no_valid_date_source' THEN 1 END) as complete_episodes
FROM episodes
WHERE imdb_id = %s
""", (imdb_id,))
result = cursor.fetchone()
if not result:
return False, "No database records found", 0
total_in_db = result['total_in_db']
complete_episodes = result['complete_episodes']
# Skip if we have episodes and all are complete
# We'll verify disk count later if needed
if total_in_db > 0 and complete_episodes == total_in_db:
return True, f"Likely complete: {complete_episodes} episodes in DB all have valid dates", total_in_db
else:
return False, f"Needs checking: {complete_episodes}/{total_in_db} episodes complete in DB", total_in_db
except Exception as e:
_log("ERROR", f"Error in fast series check for {imdb_id}: {e}")
return False, f"Error in fast check: {e}", 0
def should_skip_series(self, imdb_id: str, episodes_on_disk: int, series_name: str = "") -> Tuple[bool, str]:
"""
Determine if we should skip processing this series based on completion status
@@ -112,11 +154,20 @@ class TVProcessor:
_log("INFO", f"Processing TV series: {series_path.name}")
# Find video files first to check completion
# Fast check first - avoid expensive filesystem scan if possible
if not force_scan:
should_skip_fast, reason_fast, episodes_in_db = self.should_skip_series_fast(imdb_id, series_path.name)
if should_skip_fast:
_log("INFO", f"⚡ FAST SKIP: {series_path.name} [{imdb_id}] - {reason_fast}")
# Still update the series record to track that we've seen it
self.db.upsert_series(imdb_id, str(series_path))
return "skipped"
# Need filesystem scan - either force_scan=True or series not complete in DB
disk_episodes = find_episodes_on_disk(series_path)
_log("INFO", f"Found {len(disk_episodes)} episodes on disk")
# Check if we should skip this series (unless forced)
# Final skip check with actual episode count (unless forced)
if not force_scan:
should_skip, reason = self.should_skip_series(imdb_id, len(disk_episodes), series_path.name)
if should_skip: