mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-01-26 19:09:52 +00:00
fix: include subfolder in output asset key
This commit is contained in:
@@ -37,7 +37,7 @@ describe('resolveOutputAssetItems', () => {
|
|||||||
vi.clearAllMocks()
|
vi.clearAllMocks()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('maps outputs and excludes a filename', async () => {
|
it('maps outputs and excludes a composite output key', async () => {
|
||||||
const outputA = createOutput({
|
const outputA = createOutput({
|
||||||
filename: 'a.png',
|
filename: 'a.png',
|
||||||
nodeId: '1',
|
nodeId: '1',
|
||||||
@@ -59,14 +59,14 @@ describe('resolveOutputAssetItems', () => {
|
|||||||
|
|
||||||
const results = await resolveOutputAssetItems(metadata, {
|
const results = await resolveOutputAssetItems(metadata, {
|
||||||
createdAt: '2025-01-01T00:00:00.000Z',
|
createdAt: '2025-01-01T00:00:00.000Z',
|
||||||
excludeOutputKey: 'b.png'
|
excludeOutputKey: '2-sub-b.png'
|
||||||
})
|
})
|
||||||
|
|
||||||
expect(mocks.getJobDetail).not.toHaveBeenCalled()
|
expect(mocks.getJobDetail).not.toHaveBeenCalled()
|
||||||
expect(results).toHaveLength(1)
|
expect(results).toHaveLength(1)
|
||||||
expect(results[0]).toEqual(
|
expect(results[0]).toEqual(
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
id: 'prompt-1-1-a.png',
|
id: 'prompt-1-1-sub-a.png',
|
||||||
name: 'a.png',
|
name: 'a.png',
|
||||||
created_at: '2025-01-01T00:00:00.000Z',
|
created_at: '2025-01-01T00:00:00.000Z',
|
||||||
tags: ['output'],
|
tags: ['output'],
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ type OutputAssetMapOptions = {
|
|||||||
createdAt?: string
|
createdAt?: string
|
||||||
executionTimeInSeconds?: number
|
executionTimeInSeconds?: number
|
||||||
workflow?: OutputAssetMetadata['workflow']
|
workflow?: OutputAssetMetadata['workflow']
|
||||||
excludeFilename?: string
|
excludeOutputKey?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
type ResolveOutputAssetItemsOptions = {
|
type ResolveOutputAssetItemsOptions = {
|
||||||
@@ -31,20 +31,26 @@ function shouldLoadFullOutputs(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getOutputKey(output: ResultItemImpl): string {
|
||||||
|
return `${output.nodeId}-${output.subfolder}-${output.filename}`
|
||||||
|
}
|
||||||
|
|
||||||
function mapOutputsToAssetItems({
|
function mapOutputsToAssetItems({
|
||||||
promptId,
|
promptId,
|
||||||
outputs,
|
outputs,
|
||||||
createdAt,
|
createdAt,
|
||||||
executionTimeInSeconds,
|
executionTimeInSeconds,
|
||||||
workflow,
|
workflow,
|
||||||
excludeFilename
|
excludeOutputKey
|
||||||
}: OutputAssetMapOptions): AssetItem[] {
|
}: OutputAssetMapOptions): AssetItem[] {
|
||||||
const createdAtValue = createdAt ?? new Date().toISOString()
|
const createdAtValue = createdAt ?? new Date().toISOString()
|
||||||
|
|
||||||
return outputs
|
return outputs
|
||||||
.filter((output) => output.filename && output.filename !== excludeFilename)
|
.filter(
|
||||||
|
(output) => output.filename && getOutputKey(output) !== excludeOutputKey
|
||||||
|
)
|
||||||
.map((output) => ({
|
.map((output) => ({
|
||||||
id: `${promptId}-${output.nodeId}-${output.filename}`,
|
id: `${promptId}-${getOutputKey(output)}`,
|
||||||
name: output.filename,
|
name: output.filename,
|
||||||
size: 0,
|
size: 0,
|
||||||
created_at: createdAtValue,
|
created_at: createdAtValue,
|
||||||
@@ -79,6 +85,6 @@ export async function resolveOutputAssetItems(
|
|||||||
createdAt,
|
createdAt,
|
||||||
executionTimeInSeconds: metadata.executionTimeInSeconds,
|
executionTimeInSeconds: metadata.executionTimeInSeconds,
|
||||||
workflow: metadata.workflow,
|
workflow: metadata.workflow,
|
||||||
excludeFilename: excludeOutputKey
|
excludeOutputKey
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user