Skip to content

Commit 3819bf2

Browse files
committed
Don't show assets scan message upon calling /object_info endpoint
1 parent 20c57cb commit 3819bf2

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

app/assets/scanner.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import sqlalchemy
66

77
import folder_paths
8-
from app.database.db import create_session
8+
from app.database.db import create_session, dependencies_available
99
from app.assets.helpers import (
1010
collect_models_files, compute_relative_filename, fast_asset_file_check, get_name_and_tags_from_asset_path,
1111
list_tree,prefixes_for_root, escape_like_prefix,
@@ -16,10 +16,14 @@
1616
from app.assets.database.models import Asset, AssetCacheState, AssetInfo
1717

1818

19-
def seed_assets(roots: tuple[RootType, ...]) -> None:
19+
def seed_assets(roots: tuple[RootType, ...], enable_logging: bool = False) -> None:
2020
"""
2121
Scan the given roots and seed the assets into the database.
2222
"""
23+
if not dependencies_available():
24+
if enable_logging:
25+
logging.warning("Database dependencies not available, skipping assets scan")
26+
return
2327
t_start = time.perf_counter()
2428
created = 0
2529
skipped_existing = 0
@@ -79,14 +83,15 @@ def seed_assets(roots: tuple[RootType, ...]) -> None:
7983
created += result["inserted_infos"]
8084
sess.commit()
8185
finally:
82-
logging.info(
83-
"Assets scan(roots=%s) completed in %.3fs (created=%d, skipped_existing=%d, total_seen=%d)",
84-
roots,
85-
time.perf_counter() - t_start,
86-
created,
87-
skipped_existing,
88-
len(paths),
89-
)
86+
if enable_logging:
87+
logging.info(
88+
"Assets scan(roots=%s) completed in %.3fs (created=%d, skipped_existing=%d, total_seen=%d)",
89+
roots,
90+
time.perf_counter() - t_start,
91+
created,
92+
skipped_existing,
93+
len(paths),
94+
)
9095

9196

9297
def _fast_db_consistency_pass(

main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ def setup_database():
328328
if dependencies_available():
329329
init_db()
330330
if not args.disable_assets_autoscan:
331-
seed_assets(["models"])
331+
seed_assets(["models"], enable_logging=True)
332332
except Exception as e:
333333
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}")
334334

0 commit comments

Comments
 (0)