implement cancellation handling in CaptureService and Database, update job states accordingly
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user