summaryrefslogtreecommitdiffstats
path: root/lib/private/App
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2017-05-02 10:08:16 +0200
committerRoeland Jago Douma <roeland@famdouma.nl>2017-05-02 10:24:10 +0200
commite79424932a249b0e1568722ec0d709cd79a385ce (patch)
treeb3a5f9ec23d1252960662c3fa1515096fdded0ba /lib/private/App
parent81ee0673a51ae2fe0a0b14420dce9e7337eb1425 (diff)
downloadnextcloud-server-e79424932a249b0e1568722ec0d709cd79a385ce.tar.gz
nextcloud-server-e79424932a249b0e1568722ec0d709cd79a385ce.zip
Make sure the AppFetcher fetches the new applist from the appstore
When in the upgrade process the version in the config is still the old version. (Since we only upgrade it after the upgrade is complete). However the app list fetched from the appstore must be the new list. Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'lib/private/App')
-rw-r--r--lib/private/App/AppStore/Fetcher/AppFetcher.php29
-rw-r--r--lib/private/App/AppStore/Fetcher/Fetcher.php25
2 files changed, 43 insertions, 11 deletions
diff --git a/lib/private/App/AppStore/Fetcher/AppFetcher.php b/lib/private/App/AppStore/Fetcher/AppFetcher.php
index 7c5efafc92f..e020390988e 100644
--- a/lib/private/App/AppStore/Fetcher/AppFetcher.php
+++ b/lib/private/App/AppStore/Fetcher/AppFetcher.php
@@ -46,14 +46,7 @@ class AppFetcher extends Fetcher {
);
$this->fileName = 'apps.json';
-
- $versionArray = explode('.', $this->config->getSystemValue('version'));
- $this->endpointUrl = sprintf(
- 'https://apps.nextcloud.com/api/v1/platform/%d.%d.%d/apps.json',
- $versionArray[0],
- $versionArray[1],
- $versionArray[2]
- );
+ $this->setEndpoint();
}
/**
@@ -68,7 +61,7 @@ class AppFetcher extends Fetcher {
/** @var mixed[] $response */
$response = parent::fetch($ETag, $content);
- $ncVersion = $this->config->getSystemValue('version');
+ $ncVersion = $this->getVersion();
$ncMajorVersion = explode('.', $ncVersion)[0];
foreach($response['data'] as $dataKey => $app) {
$releases = [];
@@ -118,4 +111,22 @@ class AppFetcher extends Fetcher {
$response['data'] = array_values($response['data']);
return $response;
}
+
+ private function setEndpoint() {
+ $versionArray = explode('.', $this->getVersion());
+ $this->endpointUrl = sprintf(
+ 'https://apps.nextcloud.com/api/v1/platform/%d.%d.%d/apps.json',
+ $versionArray[0],
+ $versionArray[1],
+ $versionArray[2]
+ );
+ }
+
+ /**
+ * @param string $version
+ */
+ public function setVersion($version) {
+ parent::setVersion($version);
+ $this->setEndpoint();
+ }
}
diff --git a/lib/private/App/AppStore/Fetcher/Fetcher.php b/lib/private/App/AppStore/Fetcher/Fetcher.php
index bde925b745f..5354d334eb1 100644
--- a/lib/private/App/AppStore/Fetcher/Fetcher.php
+++ b/lib/private/App/AppStore/Fetcher/Fetcher.php
@@ -43,6 +43,8 @@ abstract class Fetcher {
protected $fileName;
/** @var string */
protected $endpointUrl;
+ /** @var string */
+ protected $version;
/**
* @param IAppData $appData
@@ -95,7 +97,7 @@ abstract class Fetcher {
}
$responseJson['timestamp'] = $this->timeFactory->getTime();
- $responseJson['ncversion'] = $this->config->getSystemValue('version');
+ $responseJson['ncversion'] = $this->getVersion();
if ($ETag !== '') {
$responseJson['ETag'] = $ETag;
}
@@ -127,7 +129,7 @@ abstract class Fetcher {
if (is_array($jsonBlob)) {
// No caching when the version has been updated
- if (isset($jsonBlob['ncversion']) && $jsonBlob['ncversion'] === $this->config->getSystemValue('version', '0.0.0')) {
+ if (isset($jsonBlob['ncversion']) && $jsonBlob['ncversion'] === $this->getVersion()) {
// If the timestamp is older than 300 seconds request the files new
if ((int)$jsonBlob['timestamp'] > ($this->timeFactory->getTime() - self::INVALIDATE_AFTER_SECONDS)) {
@@ -154,4 +156,23 @@ abstract class Fetcher {
return [];
}
}
+
+ /**
+ * Get the currently Nextcloud version
+ * @return string
+ */
+ protected function getVersion() {
+ if ($this->version === null) {
+ $this->version = $this->config->getSystemValue('version', '0.0.0');
+ }
+ return $this->version;
+ }
+
+ /**
+ * Set the current Nextcloud version
+ * @param string $version
+ */
+ public function setVersion($version) {
+ $this->version = $version;
+ }
}