mirror of
https://github.com/appwrite/appwrite
synced 2026-05-24 09:28:40 +00:00
refactor
This commit is contained in:
parent
4aaa3bfd9f
commit
aa30db2136
1 changed files with 11 additions and 8 deletions
|
|
@ -1391,21 +1391,24 @@ class Deletes extends Action
|
||||||
/**
|
/**
|
||||||
* @param Database $dbForPlatform
|
* @param Database $dbForPlatform
|
||||||
* @param callable $getProjectDB
|
* @param callable $getProjectDB
|
||||||
* @param Document $document
|
* @param Document $installation
|
||||||
* @param Document $project
|
* @param Document $project
|
||||||
* @return void
|
* @return void
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
private function deleteInstallation(Database $dbForPlatform, callable $getProjectDB, Document $document, Document $project): void
|
private function deleteInstallation(Database $dbForPlatform, callable $getProjectDB, Document $installation, Document $project): void
|
||||||
{
|
{
|
||||||
$dbForProject = $getProjectDB($project);
|
$dbForProject = $getProjectDB($project);
|
||||||
|
|
||||||
// Cleanup sites and functions
|
// Cleanup sites and functions
|
||||||
foreach (['sites', 'functions'] as $resource) {
|
foreach (['sites', 'functions'] as $collection) {
|
||||||
$this->listByGroup($resource, [
|
$this->listByGroup($collection, [
|
||||||
Query::equal('installationInternalId', [$document->getSequence()])
|
Query::equal('installationInternalId', [$installation->getSequence()])
|
||||||
], $dbForProject, function ($document) use ($resource, $dbForProject, $dbForPlatform) {
|
], $dbForProject, function ($document) use ($collection, $dbForProject, $dbForPlatform) {
|
||||||
$dbForPlatform->deleteDocument('repositories', $document->getAttribute('repositoryId'));
|
$repositoryId = $document->getAttribute('repositoryId', '');
|
||||||
|
if (!empty($repositoryId)) {
|
||||||
|
$dbForPlatform->deleteDocument('repositories', $repositoryId);
|
||||||
|
}
|
||||||
|
|
||||||
$document = $document
|
$document = $document
|
||||||
->setAttribute('installationId', '')
|
->setAttribute('installationId', '')
|
||||||
|
|
@ -1416,7 +1419,7 @@ class Deletes extends Action
|
||||||
->setAttribute('providerRootDirectory', '')
|
->setAttribute('providerRootDirectory', '')
|
||||||
->setAttribute('repositoryId', '')
|
->setAttribute('repositoryId', '')
|
||||||
->setAttribute('repositoryInternalId', '');
|
->setAttribute('repositoryInternalId', '');
|
||||||
$dbForProject->updateDocument($resource, $document->getId(), $document);
|
$dbForProject->updateDocument($collection, $document->getId(), $document);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue