From 43c191fffb6f423909488bab41d90ca3af0d6edb Mon Sep 17 00:00:00 2001 From: Thomas Müller Date: Mon, 22 Sep 2014 11:59:13 +0200 Subject: show upgrade errors as error in the console and report back that the upgrade process failed if it did --- core/command/upgrade.php | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'core/command') diff --git a/core/command/upgrade.php b/core/command/upgrade.php index d037082c5e8..722ba4f9db9 100644 --- a/core/command/upgrade.php +++ b/core/command/upgrade.php @@ -22,6 +22,8 @@ class Upgrade extends Command { const ERROR_UP_TO_DATE = 3; const ERROR_INVALID_ARGUMENTS = 4; + public $upgradeFailed = false; + protected function configure() { $this ->setName('upgrade') @@ -75,6 +77,7 @@ class Upgrade extends Command { } if(\OC::checkUpgrade(false)) { + $self = $this; $updater = new Updater(); $updater->setSimulateStepEnabled($simulateStepEnabled); @@ -83,15 +86,14 @@ class Upgrade extends Command { $updater->listen('\OC\Updater', 'maintenanceStart', function () use($output) { $output->writeln('Turned on maintenance mode'); }); - $updater->listen('\OC\Updater', 'maintenanceEnd', function () use($output, $updateStepEnabled) { - $output->writeln('Turned off maintenance mode'); - if (!$updateStepEnabled) { - $output->writeln('Update simulation successful'); - } - else { - $output->writeln('Update successful'); - } - }); + $updater->listen('\OC\Updater', 'maintenanceEnd', + function () use($output, $updateStepEnabled, $self) { + $output->writeln('Turned off maintenance mode'); + $mode = $updateStepEnabled ? 'Update' : 'Update simulation'; + $status = $self->upgradeFailed ? 'failed' : 'successful'; + $message = "$mode $status"; + $output->writeln($message); + }); $updater->listen('\OC\Updater', 'dbUpgrade', function () use($output) { $output->writeln('Updated database'); }); @@ -102,9 +104,9 @@ class Upgrade extends Command { $output->writeln('Disabled incompatible apps: ' . implode(', ', $appList) . ''); }); - $updater->listen('\OC\Updater', 'failure', function ($message) use($output) { - $output->writeln($message); - \OC_Config::setValue('maintenance', false); + $updater->listen('\OC\Updater', 'failure', function ($message) use($output, $self) { + $output->writeln("$message"); + $self->upgradeFailed = true; }); $updater->upgrade(); -- cgit v1.2.3