summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@gmx.de>2015-07-16 11:56:10 +0200
committerJoas Schilling <nickvergessen@gmx.de>2015-07-16 11:56:10 +0200
commit5c4e6b1c3ef83121dcd80442d238d0b18ffcd07f (patch)
tree47a29c6ea380926f44e85a7561105498550b760c
parent374dd3cbcb78e84e8246fb4f63c376e697943f8b (diff)
parentfba6ac505004c5d6a3fad5079bde2964302c0c9f (diff)
downloadnextcloud-server-5c4e6b1c3ef83121dcd80442d238d0b18ffcd07f.tar.gz
nextcloud-server-5c4e6b1c3ef83121dcd80442d238d0b18ffcd07f.zip
Merge pull request #17406 from owncloud/stable7-backport-17095
[stable7] Proper error handling
-rw-r--r--core/command/upgrade.php30
-rw-r--r--lib/private/files/filesystem.php2
-rw-r--r--lib/private/updater.php8
3 files changed, 27 insertions, 13 deletions
diff --git a/core/command/upgrade.php b/core/command/upgrade.php
index 22f4293149f..af3a02178f1 100644
--- a/core/command/upgrade.php
+++ b/core/command/upgrade.php
@@ -21,6 +21,7 @@ class Upgrade extends Command {
const ERROR_MAINTENANCE_MODE = 2;
const ERROR_UP_TO_DATE = 3;
const ERROR_INVALID_ARGUMENTS = 4;
+ const ERROR_FAILURE = 5;
protected function configure() {
$this
@@ -83,15 +84,18 @@ class Upgrade extends Command {
$updater->listen('\OC\Updater', 'maintenanceStart', function () use($output) {
$output->writeln('<info>Turned on maintenance mode</info>');
});
- $updater->listen('\OC\Updater', 'maintenanceEnd', function () use($output, $updateStepEnabled) {
- $output->writeln('<info>Turned off maintenance mode</info>');
- if (!$updateStepEnabled) {
- $output->writeln('<info>Update simulation successful</info>');
- }
- else {
- $output->writeln('<info>Update successful</info>');
- }
- });
+ $updater->listen('\OC\Updater', 'maintenanceEnd',
+ 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 = $success ? 'successful' : 'failed' ;
+ $type = $success ? 'info' : 'error';
+ $message = "<$type>$mode $status</$type>";
+ $output->writeln($message);
+ });
$updater->listen('\OC\Updater', 'dbUpgrade', function () use($output) {
$output->writeln('<info>Updated database</info>');
});
@@ -106,14 +110,18 @@ class Upgrade extends Command {
});
$updater->listen('\OC\Updater', 'failure', function ($message) use($output) {
- $output->writeln($message);
+ $output->writeln("<error>$message</error>");
\OC_Config::setValue('maintenance', false);
});
- $updater->upgrade();
+ $success = $updater->upgrade();
$this->postUpgradeCheck($input, $output);
+ if(!$success) {
+ return self::ERROR_FAILURE;
+ }
+
return self::ERROR_SUCCESS;
} else if(\OC_Config::getValue('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 883bd4fc6b4..cc8fe471fce 100644
--- a/lib/private/files/filesystem.php
+++ b/lib/private/files/filesystem.php
@@ -331,7 +331,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 c6c2ad2257d..64f8dc355d1 100644
--- a/lib/private/updater.php
+++ b/lib/private/updater.php
@@ -136,14 +136,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;
}
\OC_Config::setValue('maintenance', false);
$this->emit('\OC\Updater', 'maintenanceEnd');
+ $this->emit('\OC\Updater', 'updateEnd', array($success));
+
+ return $success;
}
/**