diff options
author | Morris Jobke <hey@morrisjobke.de> | 2015-06-23 11:03:27 +0300 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2015-07-06 11:41:16 +0300 |
commit | b94657a554ab25cf38c2306bcc95d02fc03e2e7c (patch) | |
tree | 1c10cc87120de4e8b8e66fa9e5ee1087042e18e0 /core | |
parent | e0bf1e4f6e1ab1cfb8e91eccfebd854d1e38d410 (diff) |
[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
Diffstat (limited to 'core')
-rw-r--r-- | core/command/upgrade.php | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/core/command/upgrade.php b/core/command/upgrade.php index a4a5be21096..09413865952 100644 --- a/core/command/upgrade.php +++ b/core/command/upgrade.php @@ -22,8 +22,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 @@ -105,10 +104,13 @@ class Upgrade extends Command { $output->writeln('<info>Turned on maintenance mode</info>'); }); $updater->listen('\OC\Updater', 'maintenanceEnd', - function () use($output, $updateStepEnabled, $self) { + function () use($output) { $output->writeln('<info>Turned off maintenance mode</info>'); + }); + $updater->listen('\OC\Updater', 'updateEnd', + function ($success) use($output, $updateStepEnabled, $self) { $mode = $updateStepEnabled ? 'Update' : 'Update simulation'; - $status = $self->upgradeFailed ? 'failed' : 'successful'; + $status = $success ? 'successful' : 'failed' ; $message = "<info>$mode $status</info>"; $output->writeln($message); }); @@ -138,13 +140,16 @@ class Upgrade extends Command { }); $updater->listen('\OC\Updater', 'failure', function ($message) use($output, $self) { $output->writeln("<error>$message</error>"); - $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 |