mirror of
https://github.com/nextcloud/server.git
synced 2026-04-29 18:11:41 -04:00
fix(OCMDiscoveryService): Also cache error results during discovery
Signed-off-by: provokateurin <kate@provokateurin.de>
This commit is contained in:
parent
28d70d1dd8
commit
8e9e893d29
1 changed files with 9 additions and 1 deletions
|
|
@ -55,7 +55,12 @@ class OCMDiscoveryService implements IOCMDiscoveryService {
|
|||
|
||||
if (!$skipCache) {
|
||||
try {
|
||||
$this->provider->import(json_decode($this->cache->get($remote) ?? '', true, 8, JSON_THROW_ON_ERROR) ?? []);
|
||||
$cached = $this->cache->get($remote);
|
||||
if ($cached === false) {
|
||||
throw new OCMProviderException('Previous discovery failed.');
|
||||
}
|
||||
|
||||
$this->provider->import(json_decode($cached ?? '', true, 8, JSON_THROW_ON_ERROR) ?? []);
|
||||
if ($this->supportedAPIVersion($this->provider->getApiVersion())) {
|
||||
return $this->provider; // if cache looks valid, we use it
|
||||
}
|
||||
|
|
@ -82,8 +87,10 @@ class OCMDiscoveryService implements IOCMDiscoveryService {
|
|||
$this->cache->set($remote, $body, 60 * 60 * 24);
|
||||
}
|
||||
} catch (JsonException|OCMProviderException $e) {
|
||||
$this->cache->set($remote, false, 5 * 60);
|
||||
throw new OCMProviderException('data returned by remote seems invalid - ' . ($body ?? ''));
|
||||
} catch (\Exception $e) {
|
||||
$this->cache->set($remote, false, 5 * 60);
|
||||
$this->logger->warning('error while discovering ocm provider', [
|
||||
'exception' => $e,
|
||||
'remote' => $remote
|
||||
|
|
@ -92,6 +99,7 @@ class OCMDiscoveryService implements IOCMDiscoveryService {
|
|||
}
|
||||
|
||||
if (!$this->supportedAPIVersion($this->provider->getApiVersion())) {
|
||||
$this->cache->set($remote, false, 5 * 60);
|
||||
throw new OCMProviderException('API version not supported');
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue