Enable pre-releases for beta and daily channel

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2019-04-08 15:22:27 +02:00
parent 9c9c410094
commit 8e278a2c38
No known key found for this signature in database
GPG Key ID: 7076EA9751AACDDA
2 changed files with 27 additions and 3 deletions

View File

@ -83,14 +83,17 @@ class AppFetcher extends Fetcher {
/** @var mixed[] $response */
$response = parent::fetch($ETag, $content);
$allowPreReleases = $this->getChannel() === 'beta' || $this->getChannel() === 'daily';
$allowNightly = $this->getChannel() === 'daily';
foreach($response['data'] as $dataKey => $app) {
$releases = [];
// Filter all compatible releases
foreach($app['releases'] as $release) {
// Exclude all nightly and pre-releases
if($release['isNightly'] === false
&& strpos($release['version'], '-') === false) {
// Exclude all nightly and pre-releases if required
if (($allowNightly || $release['isNightly'] === false)
&& ($allowPreReleases || strpos($release['version'], '-') === false)) {
// Exclude all versions not compatible with the current version
try {
$versionParser = new VersionParser();

View File

@ -57,6 +57,8 @@ abstract class Fetcher {
protected $endpointUrl;
/** @var string */
protected $version;
/** @var string */
protected $channel;
/**
* @param Factory $appDataFactory
@ -197,4 +199,23 @@ abstract class Fetcher {
public function setVersion(string $version) {
$this->version = $version;
}
/**
* Get the currently Nextcloud update channel
* @return string
*/
protected function getChannel() {
if ($this->channel === null) {
$this->channel = \OC_Util::getChannel();
}
return $this->channel;
}
/**
* Set the current Nextcloud update channel
* @param string $channel
*/
public function setChannel(string $channel) {
$this->channel = $channel;
}
}