summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2015-02-27 12:44:04 +0100
committerVincent Petry <pvince81@owncloud.com>2015-03-16 16:25:29 +0100
commit04809b603795d19c02f7a95c93146186593729b8 (patch)
tree9927e509879f25ea2300c6152e40df0012d258ab /lib
parent5538c2732276e2d1d4b30faf475b41a1e8e3681d (diff)
downloadnextcloud-server-04809b603795d19c02f7a95c93146186593729b8.tar.gz
nextcloud-server-04809b603795d19c02f7a95c93146186593729b8.zip
Properly forward repair errors and warnings
This makes repair errors and warnings visible for the user when upgrading on the command line or in the web UI.
Diffstat (limited to 'lib')
-rw-r--r--lib/private/repair/repairlegacystorages.php15
-rw-r--r--lib/private/updater.php16
2 files changed, 30 insertions, 1 deletions
diff --git a/lib/private/repair/repairlegacystorages.php b/lib/private/repair/repairlegacystorages.php
index f09ca2b5cdd..027cb68eb1b 100644
--- a/lib/private/repair/repairlegacystorages.php
+++ b/lib/private/repair/repairlegacystorages.php
@@ -143,6 +143,7 @@ class RepairLegacyStorages extends BasicEmitter {
$dataDirId = 'local::' . $dataDir;
$count = 0;
+ $hasWarnings = false;
$this->connection->beginTransaction();
@@ -167,6 +168,7 @@ class RepairLegacyStorages extends BasicEmitter {
}
}
catch (\OC\RepairException $e) {
+ $hasWarnings = true;
$this->emit(
'\OC\Repair',
'warning',
@@ -180,6 +182,7 @@ class RepairLegacyStorages extends BasicEmitter {
. ' WHERE `id` NOT LIKE \'%::%\'';
$result = $this->connection->executeQuery($sql);
$row = $result->fetch();
+
// find at least one to make sure it's worth
// querying the user list
if ((int)$row['c'] > 0) {
@@ -213,6 +216,7 @@ class RepairLegacyStorages extends BasicEmitter {
}
}
catch (\OC\RepairException $e) {
+ $hasWarnings = true;
$this->emit(
'\OC\Repair',
'warning',
@@ -229,6 +233,15 @@ class RepairLegacyStorages extends BasicEmitter {
$this->connection->commit();
- $this->config->setAppValue('core', 'repairlegacystoragesdone', 'yes');
+ if ($hasWarnings) {
+ $this->emit(
+ '\OC\Repair',
+ 'warning',
+ array('Some legacy storages could not be repaired. Please manually fix them then re-run ./occ maintenance:repair')
+ );
+ } else {
+ // if all were done, no need to redo the repair during next upgrade
+ $this->config->setAppValue('core', 'repairlegacystoragesdone', 'yes');
+ }
}
}
diff --git a/lib/private/updater.php b/lib/private/updater.php
index 485bf7ea48e..08731c731e4 100644
--- a/lib/private/updater.php
+++ b/lib/private/updater.php
@@ -173,6 +173,20 @@ class Updater extends BasicEmitter {
}
/**
+ * Forward messages emitted by the repair routine
+ *
+ * @param Repair $repair repair routine
+ */
+ private function emitRepairMessages(Repair $repair) {
+ $repair->listen('\OC\Repair', 'warning', function ($description) {
+ $this->emit('\OC\Updater', 'repairWarning', array($description));
+ });
+ $repair->listen('\OC\Repair', 'error', function ($description) {
+ $this->emit('\OC\Updater', 'repairError', array($description));
+ });
+ }
+
+ /**
* runs the update actions in maintenance mode, does not upgrade the source files
* except the main .htaccess file
*
@@ -204,6 +218,7 @@ class Updater extends BasicEmitter {
// pre-upgrade repairs
$repair = new Repair(Repair::getBeforeUpgradeRepairSteps());
+ $this->emitRepairMessages($repair);
$repair->run();
// simulate DB upgrade
@@ -223,6 +238,7 @@ class Updater extends BasicEmitter {
// post-upgrade repairs
$repair = new Repair(Repair::getRepairSteps());
+ $this->emitRepairMessages($repair);
$repair->run();
//Invalidate update feed