summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/Command/Maintenance/Repair.php69
-rw-r--r--core/register_command.php4
-rw-r--r--lib/private/Repair/DropOldTables.php5
3 files changed, 61 insertions, 17 deletions
diff --git a/core/Command/Maintenance/Repair.php b/core/Command/Maintenance/Repair.php
index 2da76143390..286df5fd7bb 100644
--- a/core/Command/Maintenance/Repair.php
+++ b/core/Command/Maintenance/Repair.php
@@ -25,24 +25,36 @@
namespace OC\Core\Command\Maintenance;
use Exception;
+use OCP\IConfig;
use Symfony\Component\Console\Command\Command;
+use Symfony\Component\Console\Helper\ProgressBar;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
+use Symfony\Component\EventDispatcher\EventDispatcher;
+use Symfony\Component\EventDispatcher\EventDispatcherInterface;
+use Symfony\Component\EventDispatcher\GenericEvent;
class Repair extends Command {
/** @var \OC\Repair $repair */
protected $repair;
- /** @var \OCP\IConfig */
+ /** @var IConfig */
protected $config;
+ /** @var EventDispatcherInterface */
+ private $dispatcher;
+ /** @var ProgressBar */
+ private $progress;
+ /** @var OutputInterface */
+ private $output;
/**
* @param \OC\Repair $repair
- * @param \OCP\IConfig $config
+ * @param IConfig $config
*/
- public function __construct(\OC\Repair $repair, \OCP\IConfig $config) {
+ public function __construct(\OC\Repair $repair, IConfig $config, EventDispatcherInterface $dispatcher) {
$this->repair = $repair;
$this->config = $config;
+ $this->dispatcher = $dispatcher;
parent::__construct();
}
@@ -87,21 +99,48 @@ class Repair extends Command {
$maintenanceMode = $this->config->getSystemValue('maintenance', false);
$this->config->setSystemValue('maintenance', true);
- $this->repair->listen('\OC\Repair', 'step', function ($description) use ($output) {
- $output->writeln(' - ' . $description);
- });
- $this->repair->listen('\OC\Repair', 'info', function ($description) use ($output) {
- $output->writeln(' - ' . $description);
- });
- $this->repair->listen('\OC\Repair', 'warning', function ($description) use ($output) {
- $output->writeln(' - WARNING: ' . $description);
- });
- $this->repair->listen('\OC\Repair', 'error', function ($description) use ($output) {
- $output->writeln(' - ERROR: ' . $description);
- });
+ $this->progress = new ProgressBar($output);
+ $this->output = $output;
+ $this->dispatcher->addListener('\OC\Repair::startProgress', [$this, 'handleRepairFeedBack']);
+ $this->dispatcher->addListener('\OC\Repair::advance', [$this, 'handleRepairFeedBack']);
+ $this->dispatcher->addListener('\OC\Repair::finishProgress', [$this, 'handleRepairFeedBack']);
+ $this->dispatcher->addListener('\OC\Repair::step', [$this, 'handleRepairFeedBack']);
+ $this->dispatcher->addListener('\OC\Repair::info', [$this, 'handleRepairFeedBack']);
+ $this->dispatcher->addListener('\OC\Repair::warning', [$this, 'handleRepairFeedBack']);
+ $this->dispatcher->addListener('\OC\Repair::error', [$this, 'handleRepairFeedBack']);
$this->repair->run();
$this->config->setSystemValue('maintenance', $maintenanceMode);
}
+
+ public function handleRepairFeedBack($event) {
+ if (!$event instanceof GenericEvent) {
+ return;
+ }
+ switch ($event->getSubject()) {
+ case '\OC\Repair::startProgress':
+ $this->progress->start($event->getArgument(0));
+ break;
+ case '\OC\Repair::advance':
+ $this->progress->advance($event->getArgument(0));
+ break;
+ case '\OC\Repair::finishProgress':
+ $this->progress->finish();
+ $this->output->writeln('');
+ break;
+ case '\OC\Repair::step':
+ $this->output->writeln(' - ' . $event->getArgument(0));
+ break;
+ case '\OC\Repair::info':
+ $this->output->writeln(' - ' . $event->getArgument(0));
+ break;
+ case '\OC\Repair::warning':
+ $this->output->writeln(' - WARNING: ' . $event->getArgument(0));
+ break;
+ case '\OC\Repair::error':
+ $this->output->writeln(' - ERROR: ' . $event->getArgument(0));
+ break;
+ }
+ }
}
diff --git a/core/register_command.php b/core/register_command.php
index 0b1a019f993..798497d97d2 100644
--- a/core/register_command.php
+++ b/core/register_command.php
@@ -112,7 +112,9 @@ if (\OC::$server->getConfig()->getSystemValue('installed', false)) {
$application->add(new OC\Core\Command\Maintenance\Mimetype\UpdateDB(\OC::$server->getMimeTypeDetector(), \OC::$server->getMimeTypeLoader()));
$application->add(new OC\Core\Command\Maintenance\Mimetype\UpdateJS(\OC::$server->getMimeTypeDetector()));
$application->add(new OC\Core\Command\Maintenance\Mode(\OC::$server->getConfig()));
- $application->add(new OC\Core\Command\Maintenance\Repair(new \OC\Repair(\OC\Repair::getRepairSteps()), \OC::$server->getConfig()));
+ $application->add(new OC\Core\Command\Maintenance\Repair(
+ new \OC\Repair(\OC\Repair::getRepairSteps(), \OC::$server->getEventDispatcher()), \OC::$server->getConfig(),
+ \OC::$server->getEventDispatcher()));
$application->add(new OC\Core\Command\Maintenance\SingleUser(\OC::$server->getConfig()));
$application->add(new OC\Core\Command\Upgrade(\OC::$server->getConfig(), \OC::$server->getLogger()));
diff --git a/lib/private/Repair/DropOldTables.php b/lib/private/Repair/DropOldTables.php
index 15d5b9a3577..59e8487c2a3 100644
--- a/lib/private/Repair/DropOldTables.php
+++ b/lib/private/Repair/DropOldTables.php
@@ -55,12 +55,15 @@ class DropOldTables implements IRepairStep {
* @throws \Exception in case of failure
*/
public function run(IOutput $output) {
+ $tables = $this->oldDatabaseTables();
+ $output->startProgress(count($tables));
foreach ($this->oldDatabaseTables() as $tableName) {
if ($this->connection->tableExists($tableName)){
- $output->info(sprintf('Table %s has been deleted', $tableName));
$this->connection->dropTable($tableName);
}
+ $output->advance();
}
+ $output->finishProgress();
}
/**