diff --git a/VERSION b/VERSION index 33e3f83..3982f4e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.8.9-multiprocess-population +2.9.1-tmp-status-file diff --git a/api/web_routes.py b/api/web_routes.py index 5b3abda..82e4c9a 100644 --- a/api/web_routes.py +++ b/api/web_routes.py @@ -15,7 +15,8 @@ from api.models import * # Status file for cross-process communication -POPULATE_STATUS_FILE = os.path.join(tempfile.gettempdir(), "nfoguard_populate_status.json") +# Use /tmp which is writable in both core and web containers +POPULATE_STATUS_FILE = "/tmp/nfoguard_populate_status.json" # Process tracking _populate_process = None diff --git a/core/database_populator.py b/core/database_populator.py index c04e121..2112062 100644 --- a/core/database_populator.py +++ b/core/database_populator.py @@ -238,6 +238,12 @@ class DatabasePopulator: stats['skipped'] += 1 continue + # Only process episodes that have video files + has_file = episode.get('hasFile', False) + if not has_file: + stats['skipped'] += 1 + continue + # Get air date aired = episode.get('airDate') @@ -249,7 +255,7 @@ class DatabasePopulator: if (season_num, episode_num) in bulk_import_dates: dateadded, source = bulk_import_dates[(season_num, episode_num)] # Fall back to API query - elif episode.get('hasFile'): + else: episode_id = episode.get('id') if episode_id: import_date = self.sonarr.get_episode_import_history(episode_id) @@ -267,7 +273,6 @@ class DatabasePopulator: continue # Insert into database - has_file = episode.get('hasFile', False) self.db.upsert_episode_date(imdb_id, season_num, episode_num, aired, dateadded, source, has_file) stats['added'] += 1 diff --git a/nfoguard-web/main_web.py b/nfoguard-web/main_web.py index 278e77f..6b01a30 100644 --- a/nfoguard-web/main_web.py +++ b/nfoguard-web/main_web.py @@ -33,7 +33,7 @@ def create_web_app() -> FastAPI: app = FastAPI( title="NFOGuard Web Interface", description="Web interface for NFOGuard media database management", - version="2.8.9-multiprocess-population", + version="2.9.0-fixes-only-files", docs_url="/docs" if web_config.web_debug else None, redoc_url="/redoc" if web_config.web_debug else None ) diff --git a/start_web.py b/start_web.py index ee400a2..c419086 100644 --- a/start_web.py +++ b/start_web.py @@ -29,7 +29,7 @@ def create_web_app() -> FastAPI: app = FastAPI( title="NFOGuard Web Interface", description="Web interface for NFOGuard media database management", - version="2.8.9-multiprocess-population", + version="2.9.0-fixes-only-files", docs_url=None, # Disable docs in production redoc_url=None ) @@ -94,7 +94,7 @@ def setup_static_files(app: FastAPI) -> None: "status": "healthy", "service": "nfoguard-web", "timestamp": time.time(), - "version": "2.8.9-multiprocess-population" + "version": "2.9.0-fixes-only-files" } except Exception as e: from fastapi import HTTPException diff --git a/utils/logging.py b/utils/logging.py index c1a4c05..d15afb7 100644 --- a/utils/logging.py +++ b/utils/logging.py @@ -96,19 +96,21 @@ def _setup_file_logging(): # Clear any existing handlers to avoid duplicates logger.handlers.clear() + # Try to set up file logging + file_logging_enabled = False try: file_handler = SafeRotatingFileHandler( log_dir / "nfoguard.log", maxBytes=50*1024*1024, backupCount=3 ) - + formatter = TimezoneAwareFormatter( '[%(asctime)s] %(levelname)s: %(message)s' ) file_handler.setFormatter(formatter) logger.addHandler(file_handler) + file_logging_enabled = True except Exception as e: - # If RotatingFileHandler fails, fall back to regular FileHandler - print(f"Warning: Could not setup rotating file handler ({e}), using regular file handler") + # If RotatingFileHandler fails, try regular FileHandler try: file_handler = logging.FileHandler(log_dir / "nfoguard.log") formatter = TimezoneAwareFormatter( @@ -116,8 +118,20 @@ def _setup_file_logging(): ) file_handler.setFormatter(formatter) logger.addHandler(file_handler) + file_logging_enabled = True except Exception as e2: - print(f"Error: Could not setup any file logging: {e2}") + # File logging not available (e.g., read-only filesystem) + # Fall back to console-only logging silently + pass + + # If file logging failed, ensure console handler is added + if not file_logging_enabled: + console_handler = logging.StreamHandler() + formatter = TimezoneAwareFormatter( + '[%(asctime)s] %(levelname)s: %(message)s' + ) + console_handler.setFormatter(formatter) + logger.addHandler(console_handler) return logger