diff options
author | John Molakvoæ <skjnldsv@users.noreply.github.com> | 2020-08-07 14:34:41 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-07 14:34:41 +0200 |
commit | d12dd3370eff809c729e8fd9548ab63161971731 (patch) | |
tree | 5277d4d9e6aebf3ad7bb18fc530507abd945a7e9 /lib/private | |
parent | a3d30bf4a23f3827103dd3ba5e10c16a58362a80 (diff) | |
parent | 9e962fb69f0afa12eeec3d2e412648a5e432588c (diff) | |
download | nextcloud-server-d12dd3370eff809c729e8fd9548ab63161971731.tar.gz nextcloud-server-d12dd3370eff809c729e8fd9548ab63161971731.zip |
Merge pull request #20741 from nextcloud/enh/appstore/unstable
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/App/AppStore/Fetcher/AppFetcher.php | 7 | ||||
-rw-r--r-- | lib/private/App/AppStore/Fetcher/Fetcher.php | 14 | ||||
-rw-r--r-- | lib/private/Installer.php | 17 |
3 files changed, 25 insertions, 13 deletions
diff --git a/lib/private/App/AppStore/Fetcher/AppFetcher.php b/lib/private/App/AppStore/Fetcher/AppFetcher.php index e4c2ba4e85e..f108d23dd9b 100644 --- a/lib/private/App/AppStore/Fetcher/AppFetcher.php +++ b/lib/private/App/AppStore/Fetcher/AppFetcher.php @@ -78,15 +78,16 @@ class AppFetcher extends Fetcher { * * @param string $ETag * @param string $content + * @param bool [$allowUnstable] Allow unstable releases * * @return array */ - protected function fetch($ETag, $content) { + protected function fetch($ETag, $content, $allowUnstable = false) { /** @var mixed[] $response */ $response = parent::fetch($ETag, $content); - $allowPreReleases = $this->getChannel() === 'beta' || $this->getChannel() === 'daily'; - $allowNightly = $this->getChannel() === 'daily'; + $allowPreReleases = $allowUnstable || $this->getChannel() === 'beta' || $this->getChannel() === 'daily'; + $allowNightly = $allowUnstable || $this->getChannel() === 'daily'; foreach ($response['data'] as $dataKey => $app) { $releases = []; diff --git a/lib/private/App/AppStore/Fetcher/Fetcher.php b/lib/private/App/AppStore/Fetcher/Fetcher.php index 500a0568c99..fcb837ee162 100644 --- a/lib/private/App/AppStore/Fetcher/Fetcher.php +++ b/lib/private/App/AppStore/Fetcher/Fetcher.php @@ -129,9 +129,10 @@ abstract class Fetcher { /** * Returns the array with the categories on the appstore server * + * @param bool [$allowUnstable] Allow unstable releases * @return array */ - public function get() { + public function get($allowUnstable = false) { $appstoreenabled = $this->config->getSystemValue('appstoreenabled', true); $internetavailable = $this->config->getSystemValue('has_internet_connection', true); @@ -148,7 +149,9 @@ abstract class Fetcher { // File does already exists $file = $rootFolder->getFile($this->fileName); $jsonBlob = json_decode($file->getContent(), true); - if (is_array($jsonBlob)) { + + // Always get latests apps info if $allowUnstable + if (!$allowUnstable && is_array($jsonBlob)) { // No caching when the version has been updated if (isset($jsonBlob['ncversion']) && $jsonBlob['ncversion'] === $this->getVersion()) { @@ -171,7 +174,12 @@ abstract class Fetcher { // Refresh the file content try { - $responseJson = $this->fetch($ETag, $content); + $responseJson = $this->fetch($ETag, $content, $allowUnstable); + // 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) { diff --git a/lib/private/Installer.php b/lib/private/Installer.php index d5c9d076eda..9be79ac72bb 100644 --- a/lib/private/Installer.php +++ b/lib/private/Installer.php @@ -189,12 +189,13 @@ class Installer { * Updates the specified app from the appstore * * @param string $appId + * @param bool [$allowUnstable] Allow unstable releases * @return bool */ - public function updateAppstoreApp($appId) { - if ($this->isUpdateAvailable($appId)) { + public function updateAppstoreApp($appId, $allowUnstable = false) { + if ($this->isUpdateAvailable($appId, $allowUnstable)) { try { - $this->downloadApp($appId); + $this->downloadApp($appId, $allowUnstable); } catch (\Exception $e) { $this->logger->logException($e, [ 'level' => ILogger::ERROR, @@ -212,13 +213,14 @@ class Installer { * Downloads an app and puts it into the app directory * * @param string $appId + * @param bool [$allowUnstable] * * @throws \Exception If the installation was not successful */ - public function downloadApp($appId) { + public function downloadApp($appId, $allowUnstable = false) { $appId = strtolower($appId); - $apps = $this->appFetcher->get(); + $apps = $this->appFetcher->get($allowUnstable); foreach ($apps as $app) { if ($app['id'] === $appId) { // Load the certificate @@ -384,9 +386,10 @@ class Installer { * Check if an update for the app is available * * @param string $appId + * @param bool $allowUnstable * @return string|false false or the version number of the update */ - public function isUpdateAvailable($appId) { + public function isUpdateAvailable($appId, $allowUnstable = false) { if ($this->isInstanceReadyForUpdates === null) { $installPath = OC_App::getInstallPath(); if ($installPath === false || $installPath === null) { @@ -405,7 +408,7 @@ class Installer { } if ($this->apps === null) { - $this->apps = $this->appFetcher->get(); + $this->apps = $this->appFetcher->get($allowUnstable); } foreach ($this->apps as $app) { |