Delete imported Comfy stills from disk instead of looking for them in the video folder.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -451,7 +451,8 @@ async function purgeOnDesktop(opts: {
|
||||
imageName: opts.imageName || '',
|
||||
imageSubfolder: opts.imageSubfolder || '',
|
||||
imageNames: (opts.extraImageNames || []).filter(Boolean),
|
||||
video: opts.video || null
|
||||
video: opts.video || null,
|
||||
output: opts.video && /\.(png|jpe?g|webp|gif)$/i.test(opts.video.filename) ? opts.video : null
|
||||
}),
|
||||
signal: AbortSignal.timeout(8000)
|
||||
})
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { createJob, emitJob, type Job } from '~/server/utils/jobs'
|
||||
import { ensureComfyReady } from '~/server/utils/comfyLifecycle'
|
||||
import { assertImageScaleToTotalPixelsNode, getComfyHost, uploadImage, queuePrompt, purgeComfyArtifacts } from '~/server/utils/comfy'
|
||||
import { withImageComfyHost, waitForImageEdit, downloadEditedImage } from '~/server/utils/imageComfy'
|
||||
import { assertImageScaleToTotalPixelsNode, getComfyHost, uploadImage, queuePrompt } from '~/server/utils/comfy'
|
||||
import { withImageComfyHost, waitForImageEdit, downloadEditedImage, purgeImageComfyArtifacts } from '~/server/utils/imageComfy'
|
||||
import { buildEditWorkflow } from '~/server/utils/imageWorkflow'
|
||||
import { ensureComfyLoraNames } from '~/server/utils/loras'
|
||||
import { imageDimensions } from '~/server/utils/resolution'
|
||||
@@ -188,11 +188,11 @@ export async function runEdit(job: Job, params: EditRunParams) {
|
||||
})
|
||||
job.stillId = still?.id
|
||||
if (!batch) parentStillId = still?.id
|
||||
await purgeComfyArtifacts({
|
||||
video: { filename: output.filename, subfolder: output.subfolder, type: output.type },
|
||||
imageName: uploaded.name,
|
||||
imageSubfolder: uploaded.subfolder,
|
||||
extraImageNames: uploadedRef?.name ? [uploadedRef.name] : [],
|
||||
await purgeImageComfyArtifacts({
|
||||
output: { filename: output.filename, subfolder: output.subfolder, type: output.type },
|
||||
inputName: uploaded.name,
|
||||
inputSubfolder: uploaded.subfolder,
|
||||
extraInputNames: uploadedRef?.name ? [uploadedRef.name] : [],
|
||||
promptId: job.promptId
|
||||
})
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { createJob, emitJob, type Job } from '~/server/utils/jobs'
|
||||
import { ensureComfyReady } from '~/server/utils/comfyLifecycle'
|
||||
import { assertImageScaleToTotalPixelsNode, getComfyHost, uploadImage, queuePrompt, purgeComfyArtifacts } from '~/server/utils/comfy'
|
||||
import { withImageComfyHost, waitForImageEdit, downloadEditedImage } from '~/server/utils/imageComfy'
|
||||
import { assertImageScaleToTotalPixelsNode, getComfyHost, uploadImage, queuePrompt } from '~/server/utils/comfy'
|
||||
import { withImageComfyHost, waitForImageEdit, downloadEditedImage, purgeImageComfyArtifacts } from '~/server/utils/imageComfy'
|
||||
import { buildImageV2Workflow, IMAGE_V2_NODE_LABELS, resolveKreaGenerateAssets } from '~/server/utils/imageWorkflowV2'
|
||||
import { ensureComfyLoraNames, persistLoraFields } from '~/server/utils/loras'
|
||||
import { imageDimensions } from '~/server/utils/resolution'
|
||||
@@ -321,11 +321,11 @@ export async function runEditV2(job: Job, params: EditV2RunParams) {
|
||||
})
|
||||
job.stillId = still?.id
|
||||
if (!batch) parentStillId = still?.id
|
||||
await purgeComfyArtifacts({
|
||||
video: { filename: output.filename, subfolder: output.subfolder, type: output.type },
|
||||
imageName: uploaded?.name,
|
||||
imageSubfolder: uploaded?.subfolder,
|
||||
extraImageNames: last
|
||||
await purgeImageComfyArtifacts({
|
||||
output: { filename: output.filename, subfolder: output.subfolder, type: output.type },
|
||||
inputName: uploaded?.name,
|
||||
inputSubfolder: uploaded?.subfolder,
|
||||
extraInputNames: last
|
||||
? [uploadedRef?.name, uploadedMask?.name].filter((name): name is string => Boolean(name))
|
||||
: [],
|
||||
promptId: job.promptId
|
||||
|
||||
@@ -365,6 +365,7 @@ async function deleteSidecarFile(file: { filename: string; subfolder?: string; t
|
||||
async function purgeImageOnDesktop(opts: {
|
||||
inputName?: string
|
||||
inputSubfolder?: string
|
||||
extraInputNames?: string[]
|
||||
output?: { filename: string; subfolder: string; type: string }
|
||||
}) {
|
||||
const config = useRuntimeConfig()
|
||||
@@ -382,9 +383,10 @@ async function purgeImageOnDesktop(opts: {
|
||||
body: JSON.stringify({
|
||||
imageName: opts.inputName || '',
|
||||
imageSubfolder: opts.inputSubfolder || '',
|
||||
imageNames: (opts.extraInputNames || []).filter(Boolean),
|
||||
output: opts.output || null
|
||||
}),
|
||||
signal: AbortSignal.timeout(4000)
|
||||
signal: AbortSignal.timeout(8000)
|
||||
})
|
||||
} catch {
|
||||
/* Host agent purge is optional; Comfy HTTP delete is the primary path. */
|
||||
@@ -395,6 +397,7 @@ export async function purgeImageComfyArtifacts(opts: {
|
||||
output?: { filename: string; subfolder: string; type: string }
|
||||
inputName?: string
|
||||
inputSubfolder?: string
|
||||
extraInputNames?: string[]
|
||||
promptId?: string
|
||||
}) {
|
||||
if (!purgeImageEnabled()) return
|
||||
@@ -413,12 +416,21 @@ export async function purgeImageComfyArtifacts(opts: {
|
||||
type: 'input'
|
||||
})
|
||||
}
|
||||
for (const name of opts.extraInputNames || []) {
|
||||
if (!name || name === opts.inputName) continue
|
||||
files.push({
|
||||
filename: name,
|
||||
subfolder: opts.inputSubfolder || '',
|
||||
type: 'input'
|
||||
})
|
||||
}
|
||||
for (const file of files) {
|
||||
await deleteSidecarFile(file)
|
||||
}
|
||||
await purgeImageOnDesktop({
|
||||
inputName: opts.inputName,
|
||||
inputSubfolder: opts.inputSubfolder,
|
||||
extraInputNames: opts.extraInputNames,
|
||||
output: opts.output
|
||||
})
|
||||
if (opts.promptId) {
|
||||
|
||||
Reference in New Issue
Block a user