Add cancellation and cleanup for native server creation
This commit is contained in:
@@ -1,7 +1,14 @@
|
||||
import { json } from '@sveltejs/kit';
|
||||
import { cancelRemoval } from '$lib/server/provisioning/index.js';
|
||||
import { cancelRemoval } from '$lib/server/provisioning/history.js';
|
||||
import { cancelCreation } from '$lib/server/provisioning/cancel-creation.js';
|
||||
import { kickProvisioning } from '$lib/server/pipeline/worker.js';
|
||||
|
||||
export function POST({ params }: { params: { id: string } }) {
|
||||
if (!cancelRemoval(params.id)) return json({ error: 'Removal has already begun or this request is no longer waiting. Refresh to see its current state.' }, { status: 409 });
|
||||
const cleanupId = cancelCreation(params.id);
|
||||
if (cleanupId) {
|
||||
void kickProvisioning();
|
||||
return json({ ok: true, cleanupId });
|
||||
}
|
||||
if (!cancelRemoval(params.id)) return json({ error: 'This operation can no longer be cancelled. Refresh to see its current state.' }, { status: 409 });
|
||||
return json({ ok: true });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user