Stop ghost extension clips and recover last-frame extract after an interrupt.
Only one Comfy finish path can save a clip, hide catalog entries whose MP4 is missing, and retry last-frame extract so a truncated file does not dump FFmpeg noise into the UI. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -70,10 +70,42 @@ export function deletePendingJob(jobId: string) {
|
||||
}
|
||||
|
||||
export async function completePendingIfReady(pending: PendingJob) {
|
||||
const alreadySaved = () => {
|
||||
const live = getJob(pending.jobId)
|
||||
if (live?.savedPromptId === pending.promptId) {
|
||||
deletePendingJob(pending.jobId)
|
||||
return {
|
||||
type: 'complete' as const,
|
||||
status: 'complete' as const,
|
||||
message: pending.folderLocked
|
||||
? 'Saved to the locked folder. Unlock it to view.'
|
||||
: (pending.extendPart1Path ? 'Extended video ready' : 'Video ready'),
|
||||
progress: 100,
|
||||
jobId: pending.jobId,
|
||||
clipId: live.clipId,
|
||||
hideThumbnail: pending.hideThumbnail,
|
||||
folderLocked: pending.folderLocked
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
const inFlight = () => {
|
||||
const current = getJob(pending.jobId)
|
||||
return Boolean(current && current.promptId === pending.promptId && current.saving)
|
||||
}
|
||||
if (inFlight()) return null
|
||||
const saved = alreadySaved()
|
||||
if (saved) return saved
|
||||
const history = await fetchHistory(pending.promptId)
|
||||
if (inFlight()) return null
|
||||
const afterHistory = alreadySaved()
|
||||
if (afterHistory) return afterHistory
|
||||
const video = extractVideo(history, pending.promptId)
|
||||
if (!video) return null
|
||||
let buffer = await downloadComfyVideo(video)
|
||||
if (inFlight()) return null
|
||||
const afterDownload = alreadySaved()
|
||||
if (afterDownload) return afterDownload
|
||||
if (pending.extendPart1Path && pending.extendTmpDir) {
|
||||
if (!existsSync(pending.extendPart1Path)) {
|
||||
removeExtendTemp(pending.extendTmpDir)
|
||||
@@ -91,6 +123,8 @@ export async function completePendingIfReady(pending: PendingJob) {
|
||||
}
|
||||
removeExtendTemp(pending.extendTmpDir)
|
||||
}
|
||||
const afterStitch = alreadySaved()
|
||||
if (afterStitch) return afterStitch
|
||||
const clip = await saveClip({
|
||||
ownerKey: pending.ownerKey,
|
||||
folderId: pending.folderId,
|
||||
|
||||
Reference in New Issue
Block a user