Line data Source code
1 : import type { LGraph } from '@/lib/litegraph/src/litegraph'
2 : import { LGraphEventMode } from '@comfyorg/graph-model/globalEnums'
3 : import { scanNodeMediaCandidates } from '@/platform/workflowErrors/missingMedia/missingMediaScan'
4 : import { useMissingMediaStore } from '@/platform/workflowErrors/missingMedia/missingMediaStore'
5 : import type { MissingMediaCandidate } from '@/platform/workflowErrors/missingMedia/types'
6 :
7 : import {
8 : createDeletedValueMatcher,
9 : findNodesReferencingValues
10 : } from './clearNodePreviewCacheForValues'
11 :
12 : /** Flags active media widgets referencing deleted assets as missing. */
13 0 : export function markDeletedAssetsAsMissingMedia(
14 : rootGraph: LGraph,
15 : deletedValues: ReadonlySet<string>
16 : ): void {
17 0 : if (deletedValues.size === 0) return
18 :
19 0 : const matchedNodes = findNodesReferencingValues(rootGraph, deletedValues, {
20 : includeSubgraphNodes: true
21 : })
22 0 : if (!matchedNodes.length) return
23 :
24 0 : const isDeleted = createDeletedValueMatcher(deletedValues)
25 0 : const candidates: MissingMediaCandidate[] = []
26 0 : for (const node of matchedNodes) {
27 0 : if (
28 : node.mode === LGraphEventMode.NEVER ||
29 : node.mode === LGraphEventMode.BYPASS
30 : )
31 0 : continue
32 0 : for (const candidate of scanNodeMediaCandidates(rootGraph, node, {
33 : includeTemp: true
34 : })) {
35 0 : if (!isDeleted(candidate.name)) continue
36 0 : candidates.push({ ...candidate, isMissing: true })
37 : }
38 : }
39 :
40 0 : if (candidates.length) {
41 0 : useMissingMediaStore().addMissingMedia(candidates)
42 : }
43 : }
|