mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
feat: accept clientJobId in batch endpoint for SSE progress correlation
This commit is contained in:
@@ -42,6 +42,7 @@ export async function registerBatchRoutes(
|
|||||||
// Parse multipart: collect all files and the settings field
|
// Parse multipart: collect all files and the settings field
|
||||||
const files: ParsedFile[] = [];
|
const files: ParsedFile[] = [];
|
||||||
let settingsRaw: string | null = null;
|
let settingsRaw: string | null = null;
|
||||||
|
let clientJobId: string | null = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const parts = request.parts();
|
const parts = request.parts();
|
||||||
@@ -60,6 +61,8 @@ export async function registerBatchRoutes(
|
|||||||
}
|
}
|
||||||
} else if (part.fieldname === "settings") {
|
} else if (part.fieldname === "settings") {
|
||||||
settingsRaw = part.value as string;
|
settingsRaw = part.value as string;
|
||||||
|
} else if (part.fieldname === "clientJobId") {
|
||||||
|
clientJobId = part.value as string;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -102,7 +105,7 @@ export async function registerBatchRoutes(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create a job ID for progress tracking
|
// Create a job ID for progress tracking
|
||||||
const jobId = randomUUID();
|
const jobId = clientJobId || randomUUID();
|
||||||
|
|
||||||
const progress: JobProgress = {
|
const progress: JobProgress = {
|
||||||
jobId,
|
jobId,
|
||||||
@@ -120,6 +123,7 @@ export async function registerBatchRoutes(
|
|||||||
"Content-Disposition": `attachment; filename="batch-${toolId}-${jobId.slice(0, 8)}.zip"`,
|
"Content-Disposition": `attachment; filename="batch-${toolId}-${jobId.slice(0, 8)}.zip"`,
|
||||||
"Transfer-Encoding": "chunked",
|
"Transfer-Encoding": "chunked",
|
||||||
"X-Job-Id": jobId,
|
"X-Job-Id": jobId,
|
||||||
|
"X-File-Order": files.map(f => f.filename).join(","),
|
||||||
});
|
});
|
||||||
|
|
||||||
// Create ZIP archive that pipes directly to the response
|
// Create ZIP archive that pipes directly to the response
|
||||||
|
|||||||
Reference in New Issue
Block a user