implement cancellation handling in CaptureService and Database, update job states accordingly

This commit is contained in:
kstyagi23
2026-09-05 06:54:10 +05:30
parent 9c1a301c1a
commit cab7a68b8b
7 changed files with 293 additions and 38 deletions
+13
View File
@@ -469,10 +469,23 @@ async function loadPublicStats() {
}
async function cancelJob(jobId) {
const current = jobs.get(jobId);
if (current && !current.cancel_requested) {
upsertJob(
{
...current,
cancel_requested: true,
phase: "Cancelling",
message: "Cancellation requested",
},
{ persist: false, connect: false },
);
}
try {
upsertJob(await request(`/api/captures/${encodeURIComponent(jobId)}/cancel`, { method: "POST" }));
void loadPublicStats();
} catch (error) {
if (current) upsertJob(current);
setMessage(error.message);
}
}