Don't show assets scan message upon calling /object_info endpoint

This commit is contained in:
Jedrzej Kosinski 2025-12-13 15:32:17 -08:00
parent 20c57cbc6a
commit 3819bf238f
2 changed files with 16 additions and 11 deletions

View File

@ -5,7 +5,7 @@ import os
import sqlalchemy import sqlalchemy
import folder_paths import folder_paths
from app.database.db import create_session from app.database.db import create_session, dependencies_available
from app.assets.helpers import ( from app.assets.helpers import (
collect_models_files, compute_relative_filename, fast_asset_file_check, get_name_and_tags_from_asset_path, collect_models_files, compute_relative_filename, fast_asset_file_check, get_name_and_tags_from_asset_path,
list_tree,prefixes_for_root, escape_like_prefix, list_tree,prefixes_for_root, escape_like_prefix,
@ -16,10 +16,14 @@ from app.assets.database.bulk_ops import seed_from_paths_batch
from app.assets.database.models import Asset, AssetCacheState, AssetInfo from app.assets.database.models import Asset, AssetCacheState, AssetInfo
def seed_assets(roots: tuple[RootType, ...]) -> None: def seed_assets(roots: tuple[RootType, ...], enable_logging: bool = False) -> None:
""" """
Scan the given roots and seed the assets into the database. Scan the given roots and seed the assets into the database.
""" """
if not dependencies_available():
if enable_logging:
logging.warning("Database dependencies not available, skipping assets scan")
return
t_start = time.perf_counter() t_start = time.perf_counter()
created = 0 created = 0
skipped_existing = 0 skipped_existing = 0
@ -79,14 +83,15 @@ def seed_assets(roots: tuple[RootType, ...]) -> None:
created += result["inserted_infos"] created += result["inserted_infos"]
sess.commit() sess.commit()
finally: finally:
logging.info( if enable_logging:
"Assets scan(roots=%s) completed in %.3fs (created=%d, skipped_existing=%d, total_seen=%d)", logging.info(
roots, "Assets scan(roots=%s) completed in %.3fs (created=%d, skipped_existing=%d, total_seen=%d)",
time.perf_counter() - t_start, roots,
created, time.perf_counter() - t_start,
skipped_existing, created,
len(paths), skipped_existing,
) len(paths),
)
def _fast_db_consistency_pass( def _fast_db_consistency_pass(

View File

@ -328,7 +328,7 @@ def setup_database():
if dependencies_available(): if dependencies_available():
init_db() init_db()
if not args.disable_assets_autoscan: if not args.disable_assets_autoscan:
seed_assets(["models"]) seed_assets(["models"], enable_logging=True)
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}")