summaryrefslogtreecommitdiffstats
path: root/lib/private/Installer.php
diff options
context:
space:
mode:
authorLukas Reschke <lukas@statuscode.ch>2017-11-27 11:48:59 +0100
committerGitHub <noreply@github.com>2017-11-27 11:48:59 +0100
commit8ccb4868762b13adc02f49654a7867b556009a41 (patch)
treebfdbb3deea57edf49122c12c05ef28b7c61a25cf /lib/private/Installer.php
parentf0d809fddecd63ca16028222a355b1c7f5aca4d9 (diff)
parentdf61d43529418aace241b99be106ff9a35188dac (diff)
downloadnextcloud-server-8ccb4868762b13adc02f49654a7867b556009a41.tar.gz
nextcloud-server-8ccb4868762b13adc02f49654a7867b556009a41.zip
Merge pull request #7264 from nextcloud/cache-fetched-apps
Cache fetched apps in update check
Diffstat (limited to 'lib/private/Installer.php')
-rw-r--r--lib/private/Installer.php25
1 files changed, 14 insertions, 11 deletions
diff --git a/lib/private/Installer.php b/lib/private/Installer.php
index 45bec26831e..48bd57f4c10 100644
--- a/lib/private/Installer.php
+++ b/lib/private/Installer.php
@@ -67,6 +67,10 @@ class Installer {
private $logger;
/** @var IConfig */
private $config;
+ /** @var array - for caching the result of app fetcher */
+ private $apps = null;
+ /** @var bool|null - for caching the result of the ready status */
+ private $isInstanceReadyForUpdates = null;
/**
* @param AppFetcher $appFetcher
@@ -187,7 +191,7 @@ class Installer {
* @return bool
*/
public function updateAppstoreApp($appId) {
- if(self::isUpdateAvailable($appId, $this->appFetcher)) {
+ if($this->isUpdateAvailable($appId)) {
try {
$this->downloadApp($appId);
} catch (\Exception $e) {
@@ -375,27 +379,26 @@ class Installer {
* Check if an update for the app is available
*
* @param string $appId
- * @param AppFetcher $appFetcher
* @return string|false false or the version number of the update
*/
- public static function isUpdateAvailable($appId,
- AppFetcher $appFetcher) {
- static $isInstanceReadyForUpdates = null;
-
- if ($isInstanceReadyForUpdates === null) {
+ public function isUpdateAvailable($appId) {
+ if ($this->isInstanceReadyForUpdates === null) {
$installPath = OC_App::getInstallPath();
if ($installPath === false || $installPath === null) {
- $isInstanceReadyForUpdates = false;
+ $this->isInstanceReadyForUpdates = false;
} else {
- $isInstanceReadyForUpdates = true;
+ $this->isInstanceReadyForUpdates = true;
}
}
- if ($isInstanceReadyForUpdates === false) {
+ if ($this->isInstanceReadyForUpdates === false) {
return false;
}
- $apps = $appFetcher->get();
+ if ($this->apps === null) {
+ $apps = $this->appFetcher->get();
+ }
+
foreach($apps as $app) {
if($app['id'] === $appId) {
$currentVersion = OC_App::getAppVersion($appId);