From fe42553e8a034ca246698144b03dc4570fe0b826 Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Tue, 23 Jun 2015 10:03:27 +0200 Subject: [updater] propagate error case properly * add $success to the updateEnd hook * add new return code for a update failure * add exception class to failure hook message --- core/command/upgrade.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'core/command/upgrade.php') diff --git a/core/command/upgrade.php b/core/command/upgrade.php index 2d6394fea85..6791d386b27 100644 --- a/core/command/upgrade.php +++ b/core/command/upgrade.php @@ -39,8 +39,7 @@ class Upgrade extends Command { const ERROR_MAINTENANCE_MODE = 2; const ERROR_UP_TO_DATE = 3; const ERROR_INVALID_ARGUMENTS = 4; - - public $upgradeFailed = false; + const ERROR_FAILURE = 5; /** * @var IConfig @@ -128,9 +127,9 @@ class Upgrade extends Command { $output->writeln('Maintenance mode is kept active'); }); $updater->listen('\OC\Updater', 'updateEnd', - function () use($output, $updateStepEnabled, $self) { + function ($success) use($output, $updateStepEnabled, $self) { $mode = $updateStepEnabled ? 'Update' : 'Update simulation'; - $status = $self->upgradeFailed ? 'failed' : 'successful'; + $status = $success ? 'successful' : 'failed' ; $message = "$mode $status"; $output->writeln($message); }); @@ -163,13 +162,16 @@ class Upgrade extends Command { }); $updater->listen('\OC\Updater', 'failure', function ($message) use($output, $self) { $output->writeln("$message"); - $self->upgradeFailed = true; }); - $updater->upgrade(); + $success = $updater->upgrade(); $this->postUpgradeCheck($input, $output); + if(!$success) { + return self::ERROR_FAILURE; + } + return self::ERROR_SUCCESS; } else if($this->config->getSystemValue('maintenance', false)) { //Possible scenario: ownCloud core is updated but an app failed -- cgit v1.2.3 From c86e129ce90c65de92172676b3798a8b48589b58 Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Tue, 23 Jun 2015 14:45:53 +0200 Subject: [updater] keep maintenance active on failure and mark failure in red --- core/command/upgrade.php | 3 ++- lib/private/updater.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'core/command/upgrade.php') diff --git a/core/command/upgrade.php b/core/command/upgrade.php index 6791d386b27..6d87f0a9891 100644 --- a/core/command/upgrade.php +++ b/core/command/upgrade.php @@ -130,7 +130,8 @@ class Upgrade extends Command { function ($success) use($output, $updateStepEnabled, $self) { $mode = $updateStepEnabled ? 'Update' : 'Update simulation'; $status = $success ? 'successful' : 'failed' ; - $message = "$mode $status"; + $type = $success ? 'info' : 'error'; + $message = "<$type>$mode $status"; $output->writeln($message); }); $updater->listen('\OC\Updater', 'dbUpgrade', function () use($output) { diff --git a/lib/private/updater.php b/lib/private/updater.php index 1b17face2e0..72998c4b3d2 100644 --- a/lib/private/updater.php +++ b/lib/private/updater.php @@ -200,7 +200,7 @@ class Updater extends BasicEmitter { $this->emit('\OC\Updater', 'updateEnd', array($success)); - if(!$wasMaintenanceModeEnabled) { + if(!$wasMaintenanceModeEnabled && $success) { $this->config->setSystemValue('maintenance', false); $this->emit('\OC\Updater', 'maintenanceDisabled'); } else { -- cgit v1.2.3