]> source.dussan.org Git - nextcloud-server.git/commitdiff
Do not ignore the max-version for the "update-available" check
authorJoas Schilling <coding@schilljs.com>
Wed, 20 Mar 2019 11:21:01 +0000 (12:21 +0100)
committerRoeland Jago Douma <roeland@famdouma.nl>
Wed, 20 Mar 2019 14:16:13 +0000 (15:16 +0100)
Signed-off-by: Joas Schilling <coding@schilljs.com>
apps/updatenotification/lib/Controller/APIController.php
lib/private/App/AppStore/Fetcher/AppFetcher.php

index 90a5fb782f5386b48e3927d886fc53924bbdb22a..0314ccf38c3b5c4f80b1b52a10bf3738f679dd88 100644 (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
                $availableApps = array_map(function(array $app) {
index 4067e03a818c3ffa68c704e5e5dd515144129763..9ad8f582460e70173a4ed4e9903dd3c4130194ad 100644 (file)
@@ -40,6 +40,9 @@ class AppFetcher extends Fetcher {
        /** @var CompareVersion */
        private $compareVersion;
 
+       /** @var bool */
+       private $ignoreMaxVersion;
+
        /**
         * @param Factory $appDataFactory
         * @param IClientService $clientService
@@ -65,6 +68,7 @@ class AppFetcher extends Fetcher {
                $this->fileName = 'apps.json';
                $this->setEndpoint();
                $this->compareVersion = $compareVersion;
+               $this->ignoreMaxVersion = true;
        }
 
        /**
@@ -93,8 +97,11 @@ class AppFetcher extends Fetcher {
                                                $version = $versionParser->getVersion($release['rawPlatformVersionSpec']);
                                                $ncVersion = $this->getVersion();
                                                $min = $version->getMinimumVersion();
+                                               $max = $version->getMaximumVersion();
                                                $minFulfilled = $this->compareVersion->isCompatible($ncVersion, $min, '>=');
-                                               if ($minFulfilled) {
+                                               $maxFulfilled = $max !== '' &&
+                                                       $this->compareVersion->isCompatible($ncVersion, $max, '<=');
+                                               if ($minFulfilled && ($this->ignoreMaxVersion || $maxFulfilled)) {
                                                        $releases[] = $release;
                                                }
                                        } catch (\InvalidArgumentException $e) {
@@ -137,10 +144,12 @@ class AppFetcher extends Fetcher {
        /**
         * @param string $version
         * @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);
                $this->fileName = $fileName;
+               $this->ignoreMaxVersion = $ignoreMaxVersion;
                $this->setEndpoint();
        }
 }