);
$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();
}
/**
/** @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 = [];
$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();
+ }
}
protected $fileName;
/** @var string */
protected $endpointUrl;
+ /** @var string */
+ protected $version;
/**
* @param IAppData $appData
}
$responseJson['timestamp'] = $this->timeFactory->getTime();
- $responseJson['ncversion'] = $this->config->getSystemValue('version');
+ $responseJson['ncversion'] = $this->getVersion();
if ($ETag !== '') {
$responseJson['ETag'] = $ETag;
}
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)) {
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;
+ }
}
$this->registerService('AppHelper', function ($c) {
return new \OC\AppHelper();
});
- $this->registerService('AppFetcher', function ($c) {
+ $this->registerService(AppFetcher::class, function ($c) {
return new AppFetcher(
$this->getAppDataDir('appstore'),
$this->getHTTPClientService(),
$this->getConfig()
);
});
+ $this->registerAlias('AppFetcher', AppFetcher::class);
+
$this->registerService('CategoryFetcher', function ($c) {
return new CategoryFetcher(
$this->getAppDataDir('appstore'),
$this->registerService(BundleFetcher::class, function () {
return new BundleFetcher($this->getL10N('lib'));
});
- $this->registerService(AppFetcher::class, function() {
- return $this->getAppFetcher();
- });
$this->registerService(\OCP\Notification\IManager::class, function (Server $c) {
return new Manager(
$c->query(IValidator::class)
namespace OC;
+use OC\App\AppStore\Fetcher\AppFetcher;
use OC\Hooks\BasicEmitter;
use OC\IntegrityCheck\Checker;
use OC_App;
$this->checkAppsRequirements();
$this->doAppUpgrade();
+ // Update the appfetchers version so it downloads the correct list from the appstore
+ \OC::$server->getAppFetcher()->setVersion($currentVersion);
+
// upgrade appstore apps
$this->upgradeAppStoreApps(\OC::$server->getAppManager()->getInstalledApps());