diff options
author | Morris Jobke <hey@morrisjobke.de> | 2015-07-09 10:23:09 +0200 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2015-07-09 10:23:09 +0200 |
commit | 3561a1572b02a54558158d6e06f220764af433d3 (patch) | |
tree | d09b17877788bb091889d6620c02f075988f7cd9 | |
parent | f97b21da11e59c00af395f6e2d5011f1f2e8963a (diff) | |
parent | ecaad05c63b78297b7b27e6d33063551d2c0e07f (diff) | |
download | nextcloud-server-3561a1572b02a54558158d6e06f220764af433d3.tar.gz nextcloud-server-3561a1572b02a54558158d6e06f220764af433d3.zip |
Merge pull request #17405 from owncloud/stable8-backport-17095
[stable8] Proper error handling
-rw-r--r-- | core/command/upgrade.php | 20 | ||||
-rw-r--r-- | lib/private/files/filesystem.php | 2 | ||||
-rw-r--r-- | lib/private/updater.php | 8 |
3 files changed, 21 insertions, 9 deletions
diff --git a/core/command/upgrade.php b/core/command/upgrade.php index a4a5be21096..d269d993f6b 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,11 +104,15 @@ 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'; - $message = "<info>$mode $status</info>"; + $status = $success ? 'successful' : 'failed' ; + $type = $success ? 'info' : 'error'; + $message = "<$type>$mode $status</$type>"; $output->writeln($message); }); $updater->listen('\OC\Updater', 'dbUpgrade', function () use($output) { @@ -138,13 +141,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 diff --git a/lib/private/files/filesystem.php b/lib/private/files/filesystem.php index 9c125f56c62..7d45d949b47 100644 --- a/lib/private/files/filesystem.php +++ b/lib/private/files/filesystem.php @@ -344,7 +344,7 @@ class Filesystem { if (is_null($userObject)) { \OCP\Util::writeLog('files', ' Backends provided no user object for '.$user, \OCP\Util::ERROR); - throw new \OC\User\NoUserException(); + throw new \OC\User\NoUserException('Backends provided no user object for ' . $user); } $homeStorage = \OC_Config::getValue( 'objectstore' ); diff --git a/lib/private/updater.php b/lib/private/updater.php index d28060c100a..4d2f3ab7d75 100644 --- a/lib/private/updater.php +++ b/lib/private/updater.php @@ -159,14 +159,20 @@ class Updater extends BasicEmitter { } $this->emit('\OC\Updater', 'maintenanceStart'); + $success = true; try { $this->doUpgrade($currentVersion, $installedVersion); } catch (\Exception $exception) { - $this->emit('\OC\Updater', 'failure', array($exception->getMessage())); + \OCP\Util::logException('update', $exception); + $this->emit('\OC\Updater', 'failure', array(get_class($exception) . ': ' .$exception->getMessage())); + $success = false; } $this->config->setSystemValue('maintenance', false); $this->emit('\OC\Updater', 'maintenanceEnd'); + $this->emit('\OC\Updater', 'updateEnd', array($success)); + + return $success; } /** |