mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-03-06 17:57:40 +08:00
Add disable/enable methods to AssetSeeder to respect --disable-assets-autoscan flag
- Added disable(), enable(), and is_disabled() methods to AssetSeeder - start() now checks is_disabled() and returns early if disabled - Updated main.py to call asset_seeder.disable() when CLI flag is set - Fixes bypass where /object_info would trigger scans regardless of flag Amp-Thread-ID: https://ampcode.com/threads/T-019c4f66-6773-72d2-bdfe-b55f5aa76021 Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
parent
8ec4d8a1d8
commit
fd30787e98
@ -97,6 +97,21 @@ class AssetSeeder:
|
|||||||
self._phase: ScanPhase = ScanPhase.FULL
|
self._phase: ScanPhase = ScanPhase.FULL
|
||||||
self._compute_hashes: bool = False
|
self._compute_hashes: bool = False
|
||||||
self._progress_callback: ProgressCallback | None = None
|
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(
|
def start(
|
||||||
self,
|
self,
|
||||||
@ -118,6 +133,9 @@ class AssetSeeder:
|
|||||||
Returns:
|
Returns:
|
||||||
True if scan was started, False if already running
|
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)
|
logging.info("Asset seeder start requested (roots=%s, phase=%s)", roots, phase.value)
|
||||||
with self._lock:
|
with self._lock:
|
||||||
if self._state != State.IDLE:
|
if self._state != State.IDLE:
|
||||||
|
|||||||
5
main.py
5
main.py
@ -359,8 +359,9 @@ def setup_database():
|
|||||||
from app.database.db import init_db, dependencies_available
|
from app.database.db import init_db, dependencies_available
|
||||||
if dependencies_available():
|
if dependencies_available():
|
||||||
init_db()
|
init_db()
|
||||||
if not args.disable_assets_autoscan:
|
if args.disable_assets_autoscan:
|
||||||
if asset_seeder.start(roots=("models", "input", "output"), prune_first=True, compute_hashes=True):
|
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")
|
logging.info("Background asset scan initiated for models, input, output")
|
||||||
except Exception as e:
|
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}")
|
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}")
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user