From 06a5e76c5047a8fe941cd9cc48d29bad5d482fe5 Mon Sep 17 00:00:00 2001 From: fogelito Date: Thu, 23 May 2024 17:42:03 +0300 Subject: [PATCH] ScheduleBase refactor --- app/init.php | 4 ++-- src/Appwrite/Platform/Tasks/ScheduleBase.php | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/init.php b/app/init.php index 57ad5fab87..45c28319f4 100644 --- a/app/init.php +++ b/app/init.php @@ -1454,9 +1454,9 @@ App::setResource('deviceForBuilds', function ($project) { return getDevice(APP_STORAGE_BUILDS . '/app-' . $project->getId()); }, ['project']); -function getDevice($root): Device +function getDevice(string $root, string $connection = null): Device { - $connection = System::getEnv('_APP_CONNECTIONS_STORAGE', ''); + $connection = empty($connection) ? System::getEnv('_APP_CONNECTIONS_STORAGE', '') : System::getEnv($connection, ''); if (!empty($connection)) { $acl = 'private'; diff --git a/src/Appwrite/Platform/Tasks/ScheduleBase.php b/src/Appwrite/Platform/Tasks/ScheduleBase.php index a50fbb2403..c8c183603e 100644 --- a/src/Appwrite/Platform/Tasks/ScheduleBase.php +++ b/src/Appwrite/Platform/Tasks/ScheduleBase.php @@ -27,7 +27,8 @@ abstract class ScheduleBase extends Action abstract protected function enqueueResources( Group $pools, - Database $dbForConsole + Database $dbForConsole, + callable $getProjectDB ); public function __construct() @@ -130,7 +131,7 @@ abstract class ScheduleBase extends Action Console::success("Starting timers at " . DateTime::now()); - run(function () use ($dbForConsole, &$lastSyncUpdate, $getSchedule, $pools) { + run(function () use ($dbForConsole, &$lastSyncUpdate, $getSchedule, $pools, $getProjectDB) { /** * The timer synchronize $schedules copy with database collection. */ @@ -190,10 +191,10 @@ abstract class ScheduleBase extends Action Timer::tick( static::ENQUEUE_TIMER * 1000, - fn () => $this->enqueueResources($pools, $dbForConsole) + fn () => $this->enqueueResources($pools, $dbForConsole, $getProjectDB) ); - $this->enqueueResources($pools, $dbForConsole); + $this->enqueueResources($pools, $dbForConsole, $getProjectDB); }); } }