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