]> source.dussan.org Git - nextcloud-server.git/commitdiff
add upgrade command before repair, handle NeedsUpgradeExcaption better 1891/head
authorJörn Friedrich Dreyer <jfd@butonic.de>
Thu, 20 Oct 2016 15:06:10 +0000 (17:06 +0200)
committerMorris Jobke <hey@morrisjobke.de>
Mon, 24 Oct 2016 15:52:49 +0000 (17:52 +0200)
core/register_command.php
lib/private/Console/Application.php

index 89b0cf31ef462403ec62a53490ceb24948f87ce6..6f31adafe926f0040e3d7d6df21c181a728e222b 100644 (file)
@@ -123,13 +123,13 @@ if (\OC::$server->getConfig()->getSystemValue('installed', false)) {
        $application->add(new OC\Core\Command\Maintenance\Mimetype\UpdateDB(\OC::$server->getMimeTypeDetector(), \OC::$server->getMimeTypeLoader()));
        $application->add(new OC\Core\Command\Maintenance\Mimetype\UpdateJS(\OC::$server->getMimeTypeDetector()));
        $application->add(new OC\Core\Command\Maintenance\Mode(\OC::$server->getConfig()));
-       $application->add(new OC\Core\Command\Maintenance\Repair(
-               new \OC\Repair(\OC\Repair::getRepairSteps(), \OC::$server->getEventDispatcher()), \OC::$server->getConfig(),
-               \OC::$server->getEventDispatcher()));
        $application->add(new OC\Core\Command\Maintenance\SingleUser(\OC::$server->getConfig()));
        $application->add(new OC\Core\Command\Maintenance\UpdateHtaccess());
 
        $application->add(new OC\Core\Command\Upgrade(\OC::$server->getConfig(), \OC::$server->getLogger()));
+       $application->add(new OC\Core\Command\Maintenance\Repair(
+               new \OC\Repair(\OC\Repair::getRepairSteps(), \OC::$server->getEventDispatcher()), \OC::$server->getConfig(),
+               \OC::$server->getEventDispatcher()));
 
        $application->add(new OC\Core\Command\User\Add(\OC::$server->getUserManager(), \OC::$server->getGroupManager()));
        $application->add(new OC\Core\Command\User\Delete(\OC::$server->getUserManager()));
index 299b23714b6a7b1af154c47fa9f48d8068f8f876..cd76b43f095c1277ebeb1d89c36c246ce89f07f6 100644 (file)
@@ -26,6 +26,7 @@
  */
 namespace OC\Console;
 
+use OC\NeedsUpdateException;
 use OC_App;
 use OCP\AppFramework\QueryException;
 use OCP\Console\ConsoleEvent;
@@ -84,39 +85,43 @@ class Application {
                if ($input->getOption('no-warnings')) {
                        $output->setVerbosity(OutputInterface::VERBOSITY_QUIET);
                }
-               require_once __DIR__ . '/../../../core/register_command.php';
-               if ($this->config->getSystemValue('installed', false)) {
-                       if (\OCP\Util::needUpgrade()) {
-                               if ($input->getArgument('command') !== '_completion') {
-                                       $output->writeln("Nextcloud or one of the apps require upgrade - only a limited number of commands are available");
-                                       $output->writeln("You may use your browser or the occ upgrade command to do the upgrade");
-                               }
-                       } elseif ($this->config->getSystemValue('maintenance', false)) {
-                               if ($input->getArgument('command') !== '_completion') {
-                                       $output->writeln("Nextcloud is in maintenance mode - no apps have been loaded");
-                               }
-                       } else {
-                               OC_App::loadApps();
-                               foreach (\OC::$server->getAppManager()->getInstalledApps() as $app) {
-                                       $appPath = \OC_App::getAppPath($app);
-                                       if($appPath === false) {
-                                               continue;
-                                       }
-                                       // load commands using info.xml
-                                       $info = \OC_App::getAppInfo($app);
-                                       if (isset($info['commands'])) {
-                                               $this->loadCommandsFromInfoXml($info['commands']);
+               try {
+                       require_once __DIR__ . '/../../../core/register_command.php';
+                       if ($this->config->getSystemValue('installed', false)) {
+                               if (\OCP\Util::needUpgrade()) {
+                                       throw new NeedsUpdateException();
+                               } elseif ($this->config->getSystemValue('maintenance', false)) {
+                                       if ($input->getArgument('command') !== '_completion') {
+                                               $output->writeln("Nextcloud is in maintenance mode - no apps have been loaded");
                                        }
-                                       // load from register_command.php
-                                       \OC_App::registerAutoloading($app, $appPath);
-                                       $file = $appPath . '/appinfo/register_command.php';
-                                       if (file_exists($file)) {
-                                               require $file;
+                               } else {
+                                       OC_App::loadApps();
+                                       foreach (\OC::$server->getAppManager()->getInstalledApps() as $app) {
+                                               $appPath = \OC_App::getAppPath($app);
+                                               if ($appPath === false) {
+                                                       continue;
+                                               }
+                                               // load commands using info.xml
+                                               $info = \OC_App::getAppInfo($app);
+                                               if (isset($info['commands'])) {
+                                                       $this->loadCommandsFromInfoXml($info['commands']);
+                                               }
+                                               // load from register_command.php
+                                               \OC_App::registerAutoloading($app, $appPath);
+                                               $file = $appPath . '/appinfo/register_command.php';
+                                               if (file_exists($file)) {
+                                                       require $file;
+                                               }
                                        }
                                }
+                       } else if ($input->getArgument('command') !== '_completion') {
+                               $output->writeln("Nextcloud is not installed - only a limited number of commands are available");
+                       }
+               } catch(NeedsUpdateException $e) {
+                       if ($input->getArgument('command') !== '_completion') {
+                               $output->writeln("Nextcloud or one of the apps require upgrade - only a limited number of commands are available");
+                               $output->writeln("You may use your browser or the occ upgrade command to do the upgrade");
                        }
-               } else if ($input->getArgument('command') !== '_completion') {
-                       $output->writeln("Nextcloud is not installed - only a limited number of commands are available");
                }
 
                if ($input->getFirstArgument() !== 'check') {