mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-04-23 07:59:07 +00:00
Fix FK constraint violation in bulk_ingest by filtering dropped assets
Co-authored-by: Amp <amp@ampcode.com> Amp-Thread-ID: https://ampcode.com/threads/T-019c3626-c6ad-7139-a570-62da4e656a1a
This commit is contained in:
@@ -16,6 +16,7 @@ from app.assets.database.queries import (
|
||||
delete_assets_by_ids,
|
||||
get_asset_info_ids_by_ids,
|
||||
get_cache_states_by_paths_and_asset_ids,
|
||||
get_existing_asset_ids,
|
||||
get_unreferenced_unhashed_asset_ids,
|
||||
mark_cache_states_missing_outside_prefixes,
|
||||
restore_cache_states_by_paths,
|
||||
@@ -202,6 +203,16 @@ def batch_insert_seed_assets(
|
||||
}
|
||||
|
||||
bulk_insert_assets(session, asset_rows)
|
||||
|
||||
# Filter cache states to only those whose assets were actually inserted
|
||||
# (assets with duplicate hashes are silently dropped by ON CONFLICT DO NOTHING)
|
||||
inserted_asset_ids = get_existing_asset_ids(
|
||||
session, [r["asset_id"] for r in cache_state_rows]
|
||||
)
|
||||
cache_state_rows = [
|
||||
r for r in cache_state_rows if r["asset_id"] in inserted_asset_ids
|
||||
]
|
||||
|
||||
bulk_insert_cache_states_ignore_conflicts(session, cache_state_rows)
|
||||
restore_cache_states_by_paths(session, absolute_path_list)
|
||||
winning_paths = get_cache_states_by_paths_and_asset_ids(session, path_to_asset_id)
|
||||
|
||||
Reference in New Issue
Block a user