Delete Comfy video, image, and audio files from the desktop after they are saved to the library.
Audio never called purge, image stills used untagged names, and a locked file could abort the whole host-agent delete. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { AsyncLocalStorage } from 'node:async_hooks'
|
||||
import { getComfyHost, viaAgentFrontDoor } from '~/server/utils/comfy'
|
||||
import { getComfyHost, viaAgentFrontDoor, comfySweepNamePrefixes } from '~/server/utils/comfy'
|
||||
import { comfyJobPrefix } from '~/utils/outputNames'
|
||||
|
||||
const imageHostAls = new AsyncLocalStorage<string>()
|
||||
@@ -369,8 +369,12 @@ async function purgeImageOnDesktop(opts: {
|
||||
output?: { filename: string; subfolder: string; type: string }
|
||||
}) {
|
||||
const config = useRuntimeConfig()
|
||||
const controlUrl = String(config.comfyControlUrl || process.env.COMFY_CONTROL_URL || '').replace(/\/$/, '')
|
||||
const token = String(config.comfyControlToken || process.env.COMFY_CONTROL_TOKEN || '')
|
||||
const controlUrl = String(
|
||||
config.imageComfyControlUrl || process.env.IMAGE_COMFY_CONTROL_URL || config.comfyControlUrl || process.env.COMFY_CONTROL_URL || ''
|
||||
).replace(/\/$/, '')
|
||||
const token = String(
|
||||
config.imageComfyControlToken || process.env.IMAGE_COMFY_CONTROL_TOKEN || config.comfyControlToken || process.env.COMFY_CONTROL_TOKEN || ''
|
||||
)
|
||||
if (!controlUrl) return
|
||||
try {
|
||||
await fetch(`${controlUrl}/purge`, {
|
||||
@@ -384,7 +388,9 @@ async function purgeImageOnDesktop(opts: {
|
||||
imageName: opts.inputName || '',
|
||||
imageSubfolder: opts.inputSubfolder || '',
|
||||
imageNames: (opts.extraInputNames || []).filter(Boolean),
|
||||
output: opts.output || null
|
||||
output: opts.output || null,
|
||||
sweepPrefixes: comfySweepNamePrefixes(),
|
||||
sweepSubfolders: ['video', 'audio', 'image', 'still']
|
||||
}),
|
||||
signal: AbortSignal.timeout(8000)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user