summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/ajax/update.php64
-rw-r--r--lib/private/Repair/DropOldTables.php2
-rw-r--r--lib/private/repair.php12
-rw-r--r--lib/public/migration/ioutput.php3
4 files changed, 69 insertions, 12 deletions
diff --git a/core/ajax/update.php b/core/ajax/update.php
index 0e6c1176ac1..f673467f64a 100644
--- a/core/ajax/update.php
+++ b/core/ajax/update.php
@@ -39,6 +39,56 @@ $eventSource = \OC::$server->createEventSource();
// message
$eventSource->send('success', (string)$l->t('Preparing update'));
+class FeedBackHandler {
+ /** @var integer */
+ private $progressStateMax = 100;
+ /** @var integer */
+ private $progressStateStep = 0;
+ /** @var string */
+ private $currentStep;
+
+ public function __construct(\OCP\IEventSource $eventSource, \OCP\IL10N $l10n) {
+ $this->eventSource = $eventSource;
+ $this->l10n = $l10n;
+ }
+
+ public function handleRepairFeedback($event) {
+ if (!$event instanceof GenericEvent) {
+ return;
+ }
+
+ switch ($event->getSubject()) {
+ case '\OC\Repair::startProgress':
+ $this->progressStateMax = $event->getArgument(0);
+ $this->progressStateStep = 0;
+ $this->currentStep = $event->getArgument(1);
+ break;
+ case '\OC\Repair::advance':
+ $this->progressStateStep += $event->getArgument(0);
+ $desc = $event->getArgument(1);
+ if (empty($desc)) {
+ $desc = $this->currentStep;
+ }
+ $this->eventSource->send('success', (string)$this->l10n->t('[%d / %d]: %s', [$this->progressStateStep, $this->progressStateMax, $desc]));
+ break;
+ case '\OC\Repair::finishProgress':
+ $this->progressStateMax = $this->progressStateStep;
+ $this->eventSource->send('success', (string)$this->l10n->t('[%d / %d]: %s', [$this->progressStateStep, $this->progressStateMax, $this->currentStep]));
+ break;
+ case '\OC\Repair::step':
+ break;
+ case '\OC\Repair::info':
+ break;
+ case '\OC\Repair::warning':
+ $this->eventSource->send('notice', (string)$this->l10n->t('Repair warning: ') . $event->getArgument(0));
+ break;
+ case '\OC\Repair::error':
+ $this->eventSource->send('notice', (string)$this->l10n->t('Repair error: ') . $event->getArgument(0));
+ break;
+ }
+ }
+}
+
if (OC::checkUpgrade(false)) {
$config = \OC::$server->getSystemConfig();
@@ -73,6 +123,14 @@ if (OC::checkUpgrade(false)) {
$eventSource->send('success', (string)$l->t('[%d / %d]: Checking table %s', [$event[0], $event[1], $event->getSubject()]));
}
});
+ $feedBack = new FeedBackHandler($eventSource, $l);
+ $dispatcher->addListener('\OC\Repair::startProgress', [$feedBack, 'handleRepairFeedback']);
+ $dispatcher->addListener('\OC\Repair::advance', [$feedBack, 'handleRepairFeedback']);
+ $dispatcher->addListener('\OC\Repair::finishProgress', [$feedBack, 'handleRepairFeedback']);
+ $dispatcher->addListener('\OC\Repair::step', [$feedBack, 'handleRepairFeedback']);
+ $dispatcher->addListener('\OC\Repair::info', [$feedBack, 'handleRepairFeedback']);
+ $dispatcher->addListener('\OC\Repair::warning', [$feedBack, 'handleRepairFeedback']);
+ $dispatcher->addListener('\OC\Repair::error', [$feedBack, 'handleRepairFeedback']);
$updater->listen('\OC\Updater', 'maintenanceEnabled', function () use ($eventSource, $l) {
$eventSource->send('success', (string)$l->t('Turned on maintenance mode'));
@@ -107,12 +165,6 @@ if (OC::checkUpgrade(false)) {
$updater->listen('\OC\Updater', 'appUpgrade', function ($app, $version) use ($eventSource, $l) {
$eventSource->send('success', (string)$l->t('Updated "%s" to %s', array($app, $version)));
});
- $updater->listen('\OC\Updater', 'repairWarning', function ($description) use ($eventSource, $l) {
- $eventSource->send('notice', (string)$l->t('Repair warning: ') . $description);
- });
- $updater->listen('\OC\Updater', 'repairError', function ($description) use ($eventSource, $l) {
- $eventSource->send('notice', (string)$l->t('Repair error: ') . $description);
- });
$updater->listen('\OC\Updater', 'incompatibleAppDisabled', function ($app) use (&$incompatibleApps) {
$incompatibleApps[]= $app;
});
diff --git a/lib/private/Repair/DropOldTables.php b/lib/private/Repair/DropOldTables.php
index 59e8487c2a3..b9963b50775 100644
--- a/lib/private/Repair/DropOldTables.php
+++ b/lib/private/Repair/DropOldTables.php
@@ -61,7 +61,7 @@ class DropOldTables implements IRepairStep {
if ($this->connection->tableExists($tableName)){
$this->connection->dropTable($tableName);
}
- $output->advance();
+ $output->advance(1, "Drop old database table: $tableName");
}
$output->finishProgress();
}
diff --git a/lib/private/repair.php b/lib/private/repair.php
index c6887ab5ce6..590b0bee721 100644
--- a/lib/private/repair.php
+++ b/lib/private/repair.php
@@ -55,6 +55,8 @@ class Repair implements IOutput{
private $repairSteps;
/** @var EventDispatcher */
private $dispatcher;
+ /** @var string */
+ private $currentStep;
/**
* Creates a new repair step runner
@@ -78,7 +80,8 @@ class Repair implements IOutput{
}
// run each repair step
foreach ($this->repairSteps as $step) {
- $this->emit('\OC\Repair', 'step', array($step->getName()));
+ $this->currentStep = $step->getName();
+ $this->emit('\OC\Repair', 'step', [$this->currentStep]);
if ($step instanceof Emitter) {
$step->listen('\OC\Repair', 'warning', function ($description) use ($self) {
@@ -206,15 +209,16 @@ class Repair implements IOutput{
*/
public function startProgress($max = 0) {
// for now just emit as we did in the past
- $this->emit('\OC\Repair', 'startProgress', [$max]);
+ $this->emit('\OC\Repair', 'startProgress', [$max, $this->currentStep]);
}
/**
* @param int $step
+ * @param string $description
*/
- public function advance($step = 1) {
+ public function advance($step = 1, $description = '') {
// for now just emit as we did in the past
- $this->emit('\OC\Repair', 'advance', [$step]);
+ $this->emit('\OC\Repair', 'advance', [$step, $description]);
}
/**
diff --git a/lib/public/migration/ioutput.php b/lib/public/migration/ioutput.php
index c52f13b31dc..d3b43028495 100644
--- a/lib/public/migration/ioutput.php
+++ b/lib/public/migration/ioutput.php
@@ -48,9 +48,10 @@ interface IOutput {
/**
* @param int $step
+ * @param string $description
* @since 9.1.0
*/
- public function advance($step = 1);
+ public function advance($step = 1, $description = '');
/**
* @param int $max