mirror of
https://github.com/nextcloud/server.git
synced 2026-06-05 14:56:35 -04:00
Merge pull request #47766 from nextcloud/backport/47754/stable28
[stable28] fix(appstore): Cache apps.json also on dev instances
This commit is contained in:
commit
bca0386000
1 changed files with 9 additions and 8 deletions
|
|
@ -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';
|
||||
|
||||
|
|
@ -170,12 +171,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'];
|
||||
}
|
||||
|
||||
|
|
@ -198,11 +204,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) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue