aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMarcel Müller <marcel-mueller@gmx.de>2024-09-04 21:13:29 +0200
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>2024-09-05 05:49:39 +0000
commit1ad173ce0519d00daed5f01b9b38870924a6b92d (patch)
treeceebe9cc3f14cf6e72dbb577b8686da3adaf8a32 /lib
parentc514a73fd36ceb617fe4c2536df1e332de54064f (diff)
downloadnextcloud-server-1ad173ce0519d00daed5f01b9b38870924a6b92d.tar.gz
nextcloud-server-1ad173ce0519d00daed5f01b9b38870924a6b92d.zip
fix(appstore): Cache apps.json also on dev instances
Signed-off-by: Marcel Müller <marcel-mueller@gmx.de>
Diffstat (limited to 'lib')
-rw-r--r--lib/private/App/AppStore/Fetcher/Fetcher.php17
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 75d2069d07a..c6781b03b02 100644
--- a/lib/private/App/AppStore/Fetcher/Fetcher.php
+++ b/lib/private/App/AppStore/Fetcher/Fetcher.php
@@ -43,6 +43,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';
@@ -157,12 +158,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'];
}
@@ -185,11 +191,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) {