Retry confirmed Studio 2 host cleanup after failures
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { purge } from './cleanup';
|
||||
import { watchProgress } from './progress';
|
||||
import { fitStill } from './media';
|
||||
import { resolveRequestSize } from './size';
|
||||
@@ -46,23 +47,6 @@ async function upload(r: any, name: string, data: Buffer): Promise<string> {
|
||||
saveRecord(r);
|
||||
return `${disk.subfolder}/${disk.filename}`;
|
||||
}
|
||||
async function purge(r: any) {
|
||||
const config = useRuntimeConfig(), prefix = String(config.comfyFilenamePrefix);
|
||||
const files = (r.files as DiskFile[]).filter(file => scopedFile(file, prefix));
|
||||
r.purgeResult = 'Left on host';
|
||||
if (files.length !== r.files.length || !files.length)
|
||||
return;
|
||||
try {
|
||||
const response = await fetch(String(config.comfyControlUrl).replace(/\/$/, '') + '/studio2/purge', {
|
||||
method: 'POST', headers: { 'Content-Type': 'application/json', ...sharedGpuHeaders() },
|
||||
body: JSON.stringify({ prefix, files }), signal: AbortSignal.timeout(12000)
|
||||
});
|
||||
const result = await response.json() as any;
|
||||
if (response.ok && result.ok && result.cleared === files.length)
|
||||
r.purgeResult = 'Cleared input + output';
|
||||
}
|
||||
catch { /* Keep the durable library copy and report unconfirmed host cleanup. */ }
|
||||
}
|
||||
async function prepareGraph(r: any) {
|
||||
const q = r.request, s = q.settings, prefix = String(useRuntimeConfig().comfyFilenamePrefix).replace(/\/$/, '') + `/studio2/${r.id}/${r.index}`;
|
||||
const load = async (id: string, label: string) => id ? upload(r, label, readFileSync(stillPath(r.owner, getStill(r.owner, id).id))) : '';
|
||||
|
||||
Reference in New Issue
Block a user