aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorKate <26026535+provokateurin@users.noreply.github.com>2024-11-25 12:42:38 +0100
committerGitHub <noreply@github.com>2024-11-25 12:42:38 +0100
commit5088b910ec4a8c003ec22822741f1664eab90175 (patch)
treeb2b77d0122aba75be80a984f4806ba3f0f7d6e9d /lib
parent1abe9de17d3057af976c77974f1648c91bc539ae (diff)
parentcc8e69c303294131f1e411629ea6866e94ea26e5 (diff)
downloadnextcloud-server-5088b910ec4a8c003ec22822741f1664eab90175.tar.gz
nextcloud-server-5088b910ec4a8c003ec22822741f1664eab90175.zip
Merge pull request #49311 from nextcloud/fix/ocmdiscoveryservice/cache-errors
Diffstat (limited to 'lib')
-rw-r--r--lib/private/OCM/OCMDiscoveryService.php10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/private/OCM/OCMDiscoveryService.php b/lib/private/OCM/OCMDiscoveryService.php
index 279162c76f2..203df4bbf9b 100644
--- a/lib/private/OCM/OCMDiscoveryService.php
+++ b/lib/private/OCM/OCMDiscoveryService.php
@@ -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
}
@@ -85,8 +90,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
@@ -95,6 +102,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');
}