1
0
Fork 0
mirror of synced 2024-07-03 13:41:01 +12:00

feat: merge conflicts

This commit is contained in:
Christy Jacob 2022-01-31 18:43:11 +04:00
parent b1a659be77
commit 0de8ff6d41
2 changed files with 9 additions and 9 deletions

View file

@ -962,7 +962,7 @@ App::delete('/v1/functions/:functionId')
->action( ->action(
function (string $functionId, string $projectId, Response $response, Database $dbForProject) use ($orchestrationPool) { function (string $functionId, string $projectId, Response $response, Database $dbForProject) use ($orchestrationPool) {
$results = $dbForProject->find('deployments', [new Query('functionId', Query::TYPE_EQUAL, [$functionId])], 999); $results = $dbForProject->find('deployments', [new Query('resourceId', Query::TYPE_EQUAL, [$functionId])], 999);
// If amount is 0 then we simply return true // If amount is 0 then we simply return true
if (count($results) === 0) { if (count($results) === 0) {
@ -975,12 +975,6 @@ App::delete('/v1/functions/:functionId')
global $register; global $register;
foreach ($results as $deployment) { foreach ($results as $deployment) {
go(function () use ($orchestrationPool, $deployment, $register, $projectId) { go(function () use ($orchestrationPool, $deployment, $register, $projectId) {
try {
$orchestration = $orchestrationPool->get();
// Remove the container of the deployment
$orchestration->remove('appwrite-function-' . $deployment['$id'], true);
Console::success('Removed container for deployment: ' . $deployment['$id']);
$db = $register->get('dbPool')->get(); $db = $register->get('dbPool')->get();
$redis = $register->get('redisPool')->get(); $redis = $register->get('redisPool')->get();
$cache = new Cache(new RedisCache($redis)); $cache = new Cache(new RedisCache($redis));
@ -988,6 +982,12 @@ App::delete('/v1/functions/:functionId')
$dbForProject->setDefaultDatabase(App::getEnv('_APP_DB_SCHEMA', 'appwrite')); $dbForProject->setDefaultDatabase(App::getEnv('_APP_DB_SCHEMA', 'appwrite'));
$dbForProject->setNamespace('_project_' . $projectId); $dbForProject->setNamespace('_project_' . $projectId);
try {
$orchestration = $orchestrationPool->get();
// Remove the container of the deployment
$orchestration->remove('appwrite-function-' . $deployment['$id'], true);
Console::success('Removed container for deployment: ' . $deployment['$id']);
$builds = $dbForProject->find('builds', [ $builds = $dbForProject->find('builds', [
new Query('deploymentId', Query::TYPE_EQUAL, [$deployment['$id']]), new Query('deploymentId', Query::TYPE_EQUAL, [$deployment['$id']]),
new Query('status', Query::TYPE_EQUAL, ['building']) new Query('status', Query::TYPE_EQUAL, ['building'])

View file

@ -348,7 +348,7 @@ class DeletesV1 extends Worker
$storageFunctions = new Local(APP_STORAGE_FUNCTIONS . '/app-' . $projectId); $storageFunctions = new Local(APP_STORAGE_FUNCTIONS . '/app-' . $projectId);
$deploymentIds = []; $deploymentIds = [];
$this->deleteByGroup('deployments', [ $this->deleteByGroup('deployments', [
new Query('functionId', Query::TYPE_EQUAL, [$document->getId()]) new Query('resourceId', Query::TYPE_EQUAL, [$document->getId()])
], $dbForProject, function (Document $document) use ($storageFunctions, &$deploymentIds) { ], $dbForProject, function (Document $document) use ($storageFunctions, &$deploymentIds) {
$deploymentIds[] = $document->getId(); $deploymentIds[] = $document->getId();
if ($storageFunctions->delete($document->getAttribute('path', ''), true)) { if ($storageFunctions->delete($document->getAttribute('path', ''), true)) {