diff --git a/app/assets/seeder.py b/app/assets/seeder.py index 3910e50b5..b5a81419b 100644 --- a/app/assets/seeder.py +++ b/app/assets/seeder.py @@ -97,6 +97,21 @@ class AssetSeeder: self._phase: ScanPhase = ScanPhase.FULL self._compute_hashes: bool = False self._progress_callback: ProgressCallback | None = None + self._disabled: bool = False + + def disable(self) -> None: + """Disable the asset seeder, preventing any scans from starting.""" + self._disabled = True + logging.info("Asset seeder disabled") + + def enable(self) -> None: + """Enable the asset seeder, allowing scans to start.""" + self._disabled = False + logging.info("Asset seeder enabled") + + def is_disabled(self) -> bool: + """Check if the asset seeder is disabled.""" + return self._disabled def start( self, @@ -118,6 +133,9 @@ class AssetSeeder: Returns: True if scan was started, False if already running """ + if self._disabled: + logging.debug("Asset seeder is disabled, skipping start") + return False logging.info("Asset seeder start requested (roots=%s, phase=%s)", roots, phase.value) with self._lock: if self._state != State.IDLE: diff --git a/main.py b/main.py index de1718df4..144bc7e34 100644 --- a/main.py +++ b/main.py @@ -360,9 +360,10 @@ def setup_database(): from app.database.db import init_db, dependencies_available if dependencies_available(): init_db() - if not args.disable_assets_autoscan: - if asset_seeder.start(roots=("models", "input", "output"), prune_first=True, compute_hashes=True): - logging.info("Background asset scan initiated for models, input, output") + if args.disable_assets_autoscan: + asset_seeder.disable() + elif asset_seeder.start(roots=("models", "input", "output"), prune_first=True, compute_hashes=True): + logging.info("Background asset scan initiated for models, input, output") except Exception as e: logging.error(f"Failed to initialize database. Please ensure you have installed the latest requirements. If the error persists, please report this as in future the database will be required: {e}")