diff options
author | Roeland Jago Douma <rullzer@users.noreply.github.com> | 2020-10-20 09:21:51 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-20 09:21:51 +0200 |
commit | ffd76d05c99fae4da9b1cc11859dd31e6e50113d (patch) | |
tree | b529fd434897896e5a58947be266fd6e106d3eb5 /lib | |
parent | f116595b3f98e5cfd1791e44364e03249cd55c5e (diff) | |
parent | 4512c73293c8843173857c825b5c1c400788f5ec (diff) | |
download | nextcloud-server-ffd76d05c99fae4da9b1cc11859dd31e6e50113d.tar.gz nextcloud-server-ffd76d05c99fae4da9b1cc11859dd31e6e50113d.zip |
Merge pull request #23374 from nextcloud/bugfix/noid/app-fetch-retry
Only retry fetching app store data once every 5 minutes in case it fails
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/App/AppStore/Fetcher/Fetcher.php | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/lib/private/App/AppStore/Fetcher/Fetcher.php b/lib/private/App/AppStore/Fetcher/Fetcher.php index a844d9d7913..305e3172c10 100644 --- a/lib/private/App/AppStore/Fetcher/Fetcher.php +++ b/lib/private/App/AppStore/Fetcher/Fetcher.php @@ -42,6 +42,7 @@ use OCP\ILogger; abstract class Fetcher { public const INVALIDATE_AFTER_SECONDS = 3600; + public const RETRY_AFTER_FAILURE_SECONDS = 300; /** @var IAppData */ protected $appData; @@ -91,6 +92,9 @@ abstract class Fetcher { */ protected function fetch($ETag, $content) { $appstoreenabled = $this->config->getSystemValue('appstoreenabled', true); + if ((int)$this->config->getAppValue('settings', 'appstore-fetcher-lastFailure', '0') > time() - self::RETRY_AFTER_FAILURE_SECONDS) { + return []; + } if (!$appstoreenabled) { return []; @@ -107,7 +111,12 @@ abstract class Fetcher { } $client = $this->clientService->newClient(); - $response = $client->get($this->getEndpoint(), $options); + try { + $response = $client->get($this->getEndpoint(), $options); + } catch (ConnectException $e) { + $this->config->setAppValue('settings', 'appstore-fetcher-lastFailure', (string)time()); + throw $e; + } $responseJson = []; if ($response->getStatusCode() === Http::STATUS_NOT_MODIFIED) { @@ -116,6 +125,7 @@ abstract class Fetcher { $responseJson['data'] = json_decode($response->getBody(), true); $ETag = $response->getHeader('ETag'); } + $this->config->deleteAppValue('settings', 'appstore-fetcher-lastFailure'); $responseJson['timestamp'] = $this->timeFactory->getTime(); $responseJson['ncversion'] = $this->getVersion(); @@ -175,6 +185,11 @@ abstract class Fetcher { // Refresh the file content try { $responseJson = $this->fetch($ETag, $content, $allowUnstable); + + if (empty($responseJson)) { + return []; + } + // Don't store the apps request file if ($allowUnstable) { return $responseJson['data']; |