update: cleanup on redirects.

This commit is contained in:
Darshan
2026-02-09 14:57:37 +05:30
parent 6454ef55ad
commit 96d94c9452
2 changed files with 26 additions and 0 deletions
@@ -861,6 +861,14 @@
const retryButton = event.target.closest('[data-install-retry]');
if (consoleButton) {
fetch('/install/cleanup', {
method: 'POST',
headers: withCsrfHeader({
'Content-Type': 'application/json'
})
}).catch(() => {});
// Redirect immediately
redirectToApp();
return;
}
@@ -57,6 +57,7 @@ class HttpHandler
$method === 'GET' && $uri === '/install/status' => $this->handleStatusRequest($uri),
$method === 'POST' && $uri === '/install/validate' => $this->handleValidateRequest($uri),
$method === 'POST' && $uri === '/install/complete' => $this->handleCompleteRequest($uri),
$method === 'POST' && $uri === '/install/cleanup' => $this->handleCleanupRequest($uri),
$method === 'POST' && $uri === '/install' => $this->handleInstallRequest($uri),
$uri === '/' => $this->handleInstallerView($uri),
default => false,
@@ -239,6 +240,23 @@ class HttpHandler
return true;
}
private function handleCleanupRequest(string $uri): bool
{
if ($_SERVER['REQUEST_METHOD'] !== 'POST' || $uri !== '/install/cleanup') {
return false;
}
header('Content-Type: application/json');
$this->validateCsrf(false);
// Remove the installer container
$container = escapeshellarg(Server::DEFAULT_CONTAINER);
@exec("docker rm -f $container >/dev/null 2>&1");
echo json_encode(['success' => true]);
return true;
}
private function handleInstallRequest(string $uri): bool
{
if ($_SERVER['REQUEST_METHOD'] !== 'POST' || $uri !== '/install') {