diff --git a/server/utils/promptComfy.ts b/server/utils/promptComfy.ts index 87c835f..ba8a4da 100644 --- a/server/utils/promptComfy.ts +++ b/server/utils/promptComfy.ts @@ -1,8 +1,8 @@ +import { comfyInputFilename } from '~/server/utils/comfy' import { getSidecarImageHost } from '~/server/utils/imageComfy' import { ensureSidecarReady } from '~/server/utils/imageComfyLifecycle' import { buildVisionPromptWorkflow } from '~/server/utils/promptWorkflow' import { normalizeShotScript } from '~/utils/parseRecommend' -import { comfyJobPrefix } from '~/utils/outputNames' export type PromptJobStatus = 'queued' | 'running' | 'complete' | 'error' @@ -42,18 +42,10 @@ async function promptComfyFetch(path: string, init?: RequestInit) { } } -function promptInputFilename(original: string, jobId?: string) { - const raw = String(original || 'still.png') - const dot = raw.lastIndexOf('.') - const ext = (dot >= 0 ? raw.slice(dot) : '.png').replace(/[^.a-zA-Z0-9]/g, '') || '.png' - const base = (dot >= 0 ? raw.slice(0, dot) : raw).replace(/[^a-zA-Z0-9._-]+/g, '_').slice(0, 48) || 'still' - return `${comfyJobPrefix(jobId)}_${base}${ext}` -} - async function uploadPromptImage(file: { filename: string; data: Buffer; type?: string }, jobId?: string) { const body = new FormData() const blob = new Blob([new Uint8Array(file.data)], { type: file.type || 'application/octet-stream' }) - const filename = promptInputFilename(file.filename, jobId) + const filename = comfyInputFilename(file.filename, file.data, jobId) body.append('image', blob, filename) body.append('overwrite', 'true') body.append('type', 'input')