1
0
Fork 0
mirror of synced 2024-07-05 14:40:42 +12:00

Throw exception for cancellation if build is already complete

This commit is contained in:
Khushboo Verma 2024-04-30 15:46:58 +05:30
parent ea9c71757c
commit fba60f974e

View file

@ -1594,6 +1594,10 @@ App::patch('/v1/functions/:functionId/deployments/:deploymentId/builds/:buildId'
throw new Exception(Exception::BUILD_NOT_FOUND);
}
if (\in_array($build->getAttribute('status'), ['ready', 'failed'])) {
throw new Exception(Exception::GENERAL_BAD_REQUEST, 'Build is already completed and cannot be cancelled.');
}
$build = $dbForProject->updateDocument('builds', $build->getId(), $build->setAttribute('status', 'cancelled'));
$executor = new Executor(App::getEnv('_APP_EXECUTOR_HOST'));