mirror of
https://github.com/nextcloud/server.git
synced 2025-02-25 09:20:16 +00:00
fix(TaskProcessing): Cache providersById in getPreferredProviders
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
This commit is contained in:
parent
c1db2eb0a9
commit
a6100021e3
1 changed files with 8 additions and 3 deletions
|
@ -80,6 +80,7 @@ class Manager implements IManager {
|
|||
|
||||
private IAppData $appData;
|
||||
private ?array $preferences = null;
|
||||
private ?array $providersById = null;
|
||||
private ICache $cache;
|
||||
private ICache $distributedCache;
|
||||
|
||||
|
@ -744,9 +745,13 @@ class Manager implements IManager {
|
|||
|
||||
$providers = $this->getProviders();
|
||||
if (isset($this->preferences[$taskTypeId])) {
|
||||
$provider = current(array_values(array_filter($providers, fn ($provider) => $provider->getId() === $this->preferences[$taskTypeId])));
|
||||
if ($provider !== false) {
|
||||
return $provider;
|
||||
$providersById = $this->providersById ?? array_reduce($providers, static function (array $carry, IProvider $provider) {
|
||||
$carry[$provider->getId()] = $provider;
|
||||
return $carry;
|
||||
}, []);
|
||||
$this->providersById = $providersById;
|
||||
if (isset($providersById[$this->preferences[$taskTypeId]])) {
|
||||
return $providersById[$this->preferences[$taskTypeId]];
|
||||
}
|
||||
}
|
||||
// By default, use the first available provider
|
||||
|
|
Loading…
Reference in a new issue