Delete Comfy input stills after library save, not only outputs.
Purge was skipping Beast input copies and never sending image names to the host agent, so studio temps piled up on the desktop. Also sweep stale hex-/aigen-prefixed inputs. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -376,6 +376,10 @@ async function purgeImageOnDesktop(opts: {
|
||||
config.imageComfyControlToken || process.env.IMAGE_COMFY_CONTROL_TOKEN || config.comfyControlToken || process.env.COMFY_CONTROL_TOKEN || ''
|
||||
)
|
||||
if (!controlUrl) return
|
||||
const imageNames = [
|
||||
opts.inputName,
|
||||
...(Array.isArray(opts.extraInputNames) ? opts.extraInputNames : [])
|
||||
].map(name => String(name || '').trim()).filter(Boolean)
|
||||
try {
|
||||
await fetch(`${controlUrl}/purge`, {
|
||||
method: 'POST',
|
||||
@@ -385,13 +389,16 @@ async function purgeImageOnDesktop(opts: {
|
||||
...(token ? { Authorization: `Bearer ${token}` } : {})
|
||||
},
|
||||
body: JSON.stringify({
|
||||
imageName: imageNames[0] || '',
|
||||
imageNames,
|
||||
imageSubfolder: opts.inputSubfolder || '',
|
||||
output: opts.output || null,
|
||||
sweep: false
|
||||
}),
|
||||
signal: AbortSignal.timeout(8000)
|
||||
})
|
||||
} catch {
|
||||
/* Host agent purge is optional; Comfy HTTP delete is the primary path. */
|
||||
/* Host agent purge is optional; Comfy HTTP delete is the fallback. */
|
||||
}
|
||||
}
|
||||
|
||||
@@ -403,6 +410,12 @@ export async function purgeImageComfyArtifacts(opts: {
|
||||
promptId?: string
|
||||
}) {
|
||||
if (!purgeImageEnabled()) return
|
||||
await purgeImageOnDesktop({
|
||||
inputName: opts.inputName,
|
||||
inputSubfolder: opts.inputSubfolder,
|
||||
extraInputNames: opts.extraInputNames,
|
||||
output: opts.output
|
||||
})
|
||||
const files: { filename: string; subfolder: string; type: string }[] = []
|
||||
if (opts.output?.filename) {
|
||||
files.push({
|
||||
@@ -411,12 +424,17 @@ export async function purgeImageComfyArtifacts(opts: {
|
||||
type: opts.output.type || 'output'
|
||||
})
|
||||
}
|
||||
const inputSub = opts.inputSubfolder || ''
|
||||
if (opts.inputName) {
|
||||
files.push({ filename: opts.inputName, subfolder: inputSub, type: 'input' })
|
||||
}
|
||||
for (const name of opts.extraInputNames || []) {
|
||||
if (!name) continue
|
||||
files.push({ filename: name, subfolder: inputSub, type: 'input' })
|
||||
}
|
||||
for (const file of files) {
|
||||
await deleteSidecarFile(file)
|
||||
}
|
||||
await purgeImageOnDesktop({
|
||||
output: opts.output
|
||||
})
|
||||
if (opts.promptId) {
|
||||
try {
|
||||
await imageComfyFetch('/history', {
|
||||
|
||||
Reference in New Issue
Block a user