Add cancellation for collection launches
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
import { json } from '@sveltejs/kit';
|
||||
import { cancelCollection } from '$lib/server/fleet/collections.js';
|
||||
import { db } from '$lib/server/db/index.js';
|
||||
import { kickProvisioning } from '$lib/server/pipeline/worker.js';
|
||||
|
||||
export function POST({ params }: { params: { id: string } }) {
|
||||
if (!db().prepare('SELECT 1 FROM server_launch_collections WHERE id=?').get(params.id)) {
|
||||
return json({ error: 'Collection not found.' }, { status: 404 });
|
||||
}
|
||||
if (!cancelCollection(params.id)) {
|
||||
return json({ error: 'This collection has no work that can still be cancelled. Refresh to see its current state.' }, { status: 409 });
|
||||
}
|
||||
void kickProvisioning();
|
||||
return json({ ok: true });
|
||||
}
|
||||
Reference in New Issue
Block a user