From 9bc263ab22efa8e8570d77354ae90c11bb05f282 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Fri, 20 Mar 2026 00:29:03 +1300 Subject: [PATCH] fix: correct stale progress file cleanup status detection Steps are keyed by step name (e.g. 'env-vars'), not by status value. The old lookup used status constants as step keys, so $status was always null and terminal-state cleanup never triggered. Detect terminal state by checking for $data['error'] (failure) or all steps having 'completed' status. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/Appwrite/Platform/Installer/Runtime/State.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/Appwrite/Platform/Installer/Runtime/State.php b/src/Appwrite/Platform/Installer/Runtime/State.php index b5a7f6edd2..5552eb5632 100644 --- a/src/Appwrite/Platform/Installer/Runtime/State.php +++ b/src/Appwrite/Platform/Installer/Runtime/State.php @@ -234,14 +234,21 @@ class State @unlink($file); continue; } - $status = $data['steps'][Server::STATUS_ERROR]['status'] - ?? $data['steps'][Server::STATUS_COMPLETED]['status'] - ?? null; $updatedAt = $data['updatedAt'] ?? 0; $age = time() - (int) $updatedAt; + $isTerminal = isset($data['error']); + if (!$isTerminal && !empty($data['steps'])) { + $isTerminal = true; + foreach ($data['steps'] as $step) { + if (($step['status'] ?? '') !== Server::STATUS_COMPLETED) { + $isTerminal = false; + break; + } + } + } if ($age > self::GLOBAL_LOCK_TIMEOUT_SECONDS) { @unlink($file); - } elseif (in_array($status, [Server::STATUS_COMPLETED, Server::STATUS_ERROR], true) && $age > 60) { + } elseif ($isTerminal && $age > 60) { @unlink($file); } }