summaryrefslogtreecommitdiffstats
path: root/core/Command
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2016-04-27 13:19:00 +0200
committerThomas Müller <thomas.mueller@tmit.eu>2016-04-28 13:52:01 +0200
commit7ad1d491f488a5c949e9c8b146d243cdd72e4d38 (patch)
treeb505e64c2a9122b82e799e16188140d0152edb65 /core/Command
parent821d8736c89eae3ad35c0ddc726a583b0c0cf99c (diff)
downloadnextcloud-server-7ad1d491f488a5c949e9c8b146d243cdd72e4d38.tar.gz
nextcloud-server-7ad1d491f488a5c949e9c8b146d243cdd72e4d38.zip
Adding progress to occ upgrade
Diffstat (limited to 'core/Command')
-rw-r--r--core/Command/Upgrade.php66
1 files changed, 51 insertions, 15 deletions
diff --git a/core/Command/Upgrade.php b/core/Command/Upgrade.php
index 1001962c6af..d61acf0451a 100644
--- a/core/Command/Upgrade.php
+++ b/core/Command/Upgrade.php
@@ -162,8 +162,59 @@ class Upgrade extends Command {
}
}
};
+ $repairListener = function($event) use ($progress, $output) {
+ if (!$event instanceof GenericEvent) {
+ return;
+ }
+ switch ($event->getSubject()) {
+ case '\OC\Repair::startProgress':
+ $progress->setMessage('Starting ...');
+ $output->writeln($event->getArgument(1));
+ $output->writeln('');
+ $progress->start($event->getArgument(0));
+ break;
+ case '\OC\Repair::advance':
+ $desc = $event->getArgument(1);
+ if (!empty($desc)) {
+ $progress->setMessage($desc);
+ }
+ $progress->advance($event->getArgument(0));
+
+ break;
+ case '\OC\Repair::finishProgress':
+ $progress->setMessage('Done');
+ $progress->finish();
+ $output->writeln('');
+ break;
+ case '\OC\Repair::step':
+ if(OutputInterface::VERBOSITY_NORMAL < $output->getVerbosity()) {
+ $output->writeln('<info>Repair step: ' . $event->getArgument(0) . '</info>');
+ }
+ break;
+ case '\OC\Repair::info':
+ if(OutputInterface::VERBOSITY_NORMAL < $output->getVerbosity()) {
+ $output->writeln('<info>Repair info: ' . $event->getArgument(0) . '</info>');
+ }
+ break;
+ case '\OC\Repair::warning':
+ $output->writeln('<error>Repair warning: ' . $event->getArgument(0) . '</error>');
+ break;
+ case '\OC\Repair::error':
+ $output->writeln('<error>Repair error: ' . $event->getArgument(0) . '</error>');
+ break;
+ }
+ };
+
$dispatcher->addListener('\OC\DB\Migrator::executeSql', $listener);
$dispatcher->addListener('\OC\DB\Migrator::checkTable', $listener);
+ $dispatcher->addListener('\OC\Repair::startProgress', $repairListener);
+ $dispatcher->addListener('\OC\Repair::advance', $repairListener);
+ $dispatcher->addListener('\OC\Repair::finishProgress', $repairListener);
+ $dispatcher->addListener('\OC\Repair::step', $repairListener);
+ $dispatcher->addListener('\OC\Repair::info', $repairListener);
+ $dispatcher->addListener('\OC\Repair::warning', $repairListener);
+ $dispatcher->addListener('\OC\Repair::error', $repairListener);
+
$updater->listen('\OC\Updater', 'maintenanceEnabled', function () use($output) {
$output->writeln('<info>Turned on maintenance mode</info>');
@@ -205,12 +256,6 @@ class Upgrade extends Command {
$updater->listen('\OC\Updater', 'upgradeAppStoreApp', function ($app) use($output) {
$output->writeln('<info>Update 3rd-party app: ' . $app . '</info>');
});
- $updater->listen('\OC\Updater', 'repairWarning', function ($app) use($output) {
- $output->writeln('<error>Repair warning: ' . $app . '</error>');
- });
- $updater->listen('\OC\Updater', 'repairError', function ($app) use($output) {
- $output->writeln('<error>Repair error: ' . $app . '</error>');
- });
$updater->listen('\OC\Updater', 'appUpgradeCheckBefore', function () use ($output) {
$output->writeln('<info>Checking updates of apps</info>');
});
@@ -242,15 +287,6 @@ class Upgrade extends Command {
$output->writeln("<info>Finished code integrity check</info>");
});
- if(OutputInterface::VERBOSITY_NORMAL < $output->getVerbosity()) {
- $updater->listen('\OC\Updater', 'repairInfo', function ($message) use($output) {
- $output->writeln('<info>Repair info: ' . $message . '</info>');
- });
- $updater->listen('\OC\Updater', 'repairStep', function ($message) use($output) {
- $output->writeln('<info>Repair step: ' . $message . '</info>');
- });
- }
-
$success = $updater->upgrade();
$this->postUpgradeCheck($input, $output);