mirror of
https://github.com/appwrite/appwrite
synced 2026-05-23 00:49:02 +00:00
Use getProjectDB instead of new function
This commit is contained in:
parent
4b0ef4598b
commit
d49de9c6cf
2 changed files with 11 additions and 22 deletions
|
|
@ -254,7 +254,7 @@ class DeletesV1 extends Worker
|
|||
protected function deleteProject(Document $document): void
|
||||
{
|
||||
// Delete project tables
|
||||
$dbForProject = $this->getProjectDBFromDocument($document);
|
||||
$dbForProject = $this->getProjectDB($document->getId(), $document);
|
||||
|
||||
$limit = 50;
|
||||
$offset = 0;
|
||||
|
|
|
|||
|
|
@ -165,31 +165,20 @@ abstract class Worker
|
|||
* @return Database
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function getProjectDB(string $projectId): Database
|
||||
protected function getProjectDB(string $projectId, ?Document $project = null): Database
|
||||
{
|
||||
$consoleDB = $this->getConsoleDB();
|
||||
if ($project === null) {
|
||||
$consoleDB = $this->getConsoleDB();
|
||||
|
||||
if ($projectId === 'console') {
|
||||
return $consoleDB;
|
||||
if ($projectId === 'console') {
|
||||
return $consoleDB;
|
||||
}
|
||||
|
||||
/** @var Document $project */
|
||||
$project = Authorization::skip(fn() => $consoleDB->getDocument('projects', $projectId));
|
||||
}
|
||||
|
||||
/** @var Document $project */
|
||||
$project = Authorization::skip(fn() => $consoleDB->getDocument('projects', $projectId));
|
||||
|
||||
return $this->getDB(self::DATABASE_PROJECT, $projectId, $project->getInternalId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get internal project database given the project document
|
||||
*
|
||||
* Allows avoiding race conditions when modifying the projects collection
|
||||
* @param Document $project
|
||||
* @return Database
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function getProjectDBFromDocument(Document $project): Database
|
||||
{
|
||||
return $this->getDB(self::DATABASE_PROJECT, project: $project);
|
||||
return $this->getDB(self::DATABASE_PROJECT, $projectId, $project->getInternalId(), $project);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue