diff options
author | Andy Scherzinger <info@andy-scherzinger.de> | 2024-09-05 09:17:40 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-05 09:17:40 +0200 |
commit | 332b3efdf0df6bd489d83f58e8ffa677749d0774 (patch) | |
tree | d7cfce750ac272878e50a0f8870a33276be4d3a9 /lib | |
parent | 8cded1e32075869ac7fbd2b528d4106cf9e04e79 (diff) | |
parent | b2c2c93a035ecf454eee85ecf2cd04f14fa57ff4 (diff) | |
download | nextcloud-server-332b3efdf0df6bd489d83f58e8ffa677749d0774.tar.gz nextcloud-server-332b3efdf0df6bd489d83f58e8ffa677749d0774.zip |
Merge pull request #47754 from nextcloud/fix/noid/cache-appstore-on-dev-instances
fix(appstore): Cache apps.json also on dev instances
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/App/AppStore/Fetcher/Fetcher.php | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/lib/private/App/AppStore/Fetcher/Fetcher.php b/lib/private/App/AppStore/Fetcher/Fetcher.php index 28252f264c3..bc85be662df 100644 --- a/lib/private/App/AppStore/Fetcher/Fetcher.php +++ b/lib/private/App/AppStore/Fetcher/Fetcher.php @@ -18,6 +18,7 @@ use Psr\Log\LoggerInterface; abstract class Fetcher { public const INVALIDATE_AFTER_SECONDS = 3600; + public const INVALIDATE_AFTER_SECONDS_UNSTABLE = 900; public const RETRY_AFTER_FAILURE_SECONDS = 300; public const APP_STORE_URL = 'https://apps.nextcloud.com/api/v1'; @@ -133,12 +134,17 @@ abstract class Fetcher { $file = $rootFolder->getFile($this->fileName); $jsonBlob = json_decode($file->getContent(), true); - // Always get latests apps info if $allowUnstable - if (!$allowUnstable && is_array($jsonBlob)) { + if (is_array($jsonBlob)) { // No caching when the version has been updated if (isset($jsonBlob['ncversion']) && $jsonBlob['ncversion'] === $this->getVersion()) { // If the timestamp is older than 3600 seconds request the files new - if ((int)$jsonBlob['timestamp'] > ($this->timeFactory->getTime() - self::INVALIDATE_AFTER_SECONDS)) { + $invalidateAfterSeconds = self::INVALIDATE_AFTER_SECONDS; + + if ($allowUnstable) { + $invalidateAfterSeconds = self::INVALIDATE_AFTER_SECONDS_UNSTABLE; + } + + if ((int)$jsonBlob['timestamp'] > ($this->timeFactory->getTime() - $invalidateAfterSeconds)) { return $jsonBlob['data']; } @@ -161,11 +167,6 @@ abstract class Fetcher { return []; } - // Don't store the apps request file - if ($allowUnstable) { - return $responseJson['data']; - } - $file->putContent(json_encode($responseJson)); return json_decode($file->getContent(), true)['data']; } catch (ConnectException $e) { |