Do not ignore the max-version for the "update-available" check

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2019-03-20 12:21:01 +01:00 committed by Roeland Jago Douma
parent 95c9e0edd2
commit 2d00e2bbe7
No known key found for this signature in database
GPG Key ID: F941078878347C0C
2 changed files with 12 additions and 3 deletions

View File

@ -90,7 +90,7 @@ class APIController extends OCSController {
]); ]);
} }
$this->appFetcher->setVersion($newVersion, 'future-apps.json'); $this->appFetcher->setVersion($newVersion, 'future-apps.json', false);
// Apps available on the app store for that version // Apps available on the app store for that version
$availableApps = array_map(function(array $app) { $availableApps = array_map(function(array $app) {

View File

@ -40,6 +40,9 @@ class AppFetcher extends Fetcher {
/** @var CompareVersion */ /** @var CompareVersion */
private $compareVersion; private $compareVersion;
/** @var bool */
private $ignoreMaxVersion;
/** /**
* @param Factory $appDataFactory * @param Factory $appDataFactory
* @param IClientService $clientService * @param IClientService $clientService
@ -65,6 +68,7 @@ class AppFetcher extends Fetcher {
$this->fileName = 'apps.json'; $this->fileName = 'apps.json';
$this->setEndpoint(); $this->setEndpoint();
$this->compareVersion = $compareVersion; $this->compareVersion = $compareVersion;
$this->ignoreMaxVersion = true;
} }
/** /**
@ -93,8 +97,11 @@ class AppFetcher extends Fetcher {
$version = $versionParser->getVersion($release['rawPlatformVersionSpec']); $version = $versionParser->getVersion($release['rawPlatformVersionSpec']);
$ncVersion = $this->getVersion(); $ncVersion = $this->getVersion();
$min = $version->getMinimumVersion(); $min = $version->getMinimumVersion();
$max = $version->getMaximumVersion();
$minFulfilled = $this->compareVersion->isCompatible($ncVersion, $min, '>='); $minFulfilled = $this->compareVersion->isCompatible($ncVersion, $min, '>=');
if ($minFulfilled) { $maxFulfilled = $max !== '' &&
$this->compareVersion->isCompatible($ncVersion, $max, '<=');
if ($minFulfilled && ($this->ignoreMaxVersion || $maxFulfilled)) {
$releases[] = $release; $releases[] = $release;
} }
} catch (\InvalidArgumentException $e) { } catch (\InvalidArgumentException $e) {
@ -137,10 +144,12 @@ class AppFetcher extends Fetcher {
/** /**
* @param string $version * @param string $version
* @param string $fileName * @param string $fileName
* @param bool $ignoreMaxVersion
*/ */
public function setVersion(string $version, string $fileName = 'apps.json') { public function setVersion(string $version, string $fileName = 'apps.json', bool $ignoreMaxVersion = true) {
parent::setVersion($version); parent::setVersion($version);
$this->fileName = $fileName; $this->fileName = $fileName;
$this->ignoreMaxVersion = $ignoreMaxVersion;
$this->setEndpoint(); $this->setEndpoint();
} }
} }