/** * Produce complete feed URL * @return string */ protected function getFeedUrl() { $currentVersion = $this->configReader->getByPath('system.version'); $version = explode('.', $currentVersion); $version['installed'] = $this->configReader->getByPath('apps.core.installedat'); $version['updated'] = $this->configReader->getByPath('apps.core.lastupdatedat'); $version['updatechannel'] = $this->getUpdateChannel(); $version['edition'] = $this->configReader->getEdition(); $version['build'] = $this->locator->getBuild(); $url = self::DEFAULT_BASE_URL . '?version=' . implode('x', $version); return $url; }
/** * Produce complete feed URL * @return string */ protected function getFeedUrl() { $currentVersion = $this->configReader->getByPath('system.version'); $version = explode('.', $currentVersion); $version['installed'] = $this->configReader->getByPath('apps.core.installedat'); $version['updated'] = $this->configReader->getByPath('apps.core.lastupdatedat'); $version['updatechannel'] = $this->getUpdateChannel(); $version['edition'] = $this->configReader->getEdition(); $version['build'] = $this->locator->getBuild(); // Read updater server URL from config $updaterServerUrl = $this->configReader->get(['system', 'updater.server.url']); if ((bool) $updaterServerUrl === false) { $updaterServerUrl = self::DEFAULT_BASE_URL; } $url = $updaterServerUrl . '?version=' . implode('x', $version); return $url; }
protected function execute(InputInterface $input, OutputInterface $output) { $registry = $this->container['utils.registry']; $registry->set('feed', false); $fsHelper = $this->container['utils.filesystemhelper']; $downloadController = new DownloadController($this->fetcher, $registry, $fsHelper); try { $currentVersion = $this->configReader->getByPath('system.version'); if (!strlen($currentVersion)) { throw new \UnexpectedValueException('Could not detect installed version.'); } $this->getApplication()->getLogger()->info('ownCloud ' . $currentVersion . ' found'); $output->writeln('Current version is ' . $currentVersion); $feedData = $downloadController->checkFeed(); if (!$feedData['success']) { // Network errors, etc $output->writeln("Can't fetch feed."); $output->writeln($feedData['exception']->getMessage()); $this->getApplication()->logException($feedData['exception']); // Return a number to stop the queue return $input->getOption('exit-if-none') ? 4 : null; } $feed = $feedData['data']['feed']; if (!$feed->isValid()) { // Feed is empty. Means there are no updates $output->writeln('No updates found online.'); return $input->getOption('exit-if-none') ? 4 : null; } $registry->set('feed', $feed); $output->writeln($feed->getVersionString() . ' is found online'); if ($input->getOption('only-check')) { return; } $action = $this->ask($input, $output); if ($action === 'abort') { $output->writeln('Exiting on user command.'); return 128; } $this->output = $output; $packageData = $downloadController->downloadOwncloud([$this, 'progress']); //Empty line, in order not to overwrite the progress message $this->output->writeln(''); if (!$packageData['success']) { $registry->set('feed', null); throw $packageData['exception']; } if ($action === 'download') { $output->writeln('Downloading has been completed. Exiting.'); return 64; } } catch (\GuzzleHttp\Exception\ClientException $e) { $this->getApplication()->getLogger()->error($e->getMessage()); $output->writeln('<error>Network error</error>'); $output->writeln(sprintf('<error>Error %d: %s while fetching an URL %s</error>', $e->getCode(), $e->getResponse()->getReasonPhrase(), $e->getResponse()->getEffectiveUrl())); return 2; } catch (\Exception $e) { $this->getApplication()->getLogger()->error($e->getMessage()); $output->writeln('<error>' . $e->getMessage() . '</error>'); return 2; } }