diff options
author | Vincent Petry <pvince81@owncloud.com> | 2016-04-29 13:47:15 +0200 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2016-04-29 13:47:15 +0200 |
commit | 6571da1519b76dce45b6a9c0b88aefd548251625 (patch) | |
tree | 32c1ea4492b96b90482194422cb710e0f945bcc4 /lib | |
parent | 5b45f0f91448f109ff33d4fb03368a0405e1da10 (diff) | |
parent | 7ad1d491f488a5c949e9c8b146d243cdd72e4d38 (diff) | |
download | nextcloud-server-6571da1519b76dce45b6a9c0b88aefd548251625.tar.gz nextcloud-server-6571da1519b76dce45b6a9c0b88aefd548251625.zip |
Merge pull request #24305 from owncloud/update-show-repair-step-progress
[Update] show repair step progress ...
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/Repair/DropOldTables.php | 5 | ||||
-rw-r--r-- | lib/private/repair.php | 20 | ||||
-rw-r--r-- | lib/private/updater.php | 29 | ||||
-rw-r--r-- | lib/public/migration/ioutput.php | 3 |
4 files changed, 22 insertions, 35 deletions
diff --git a/lib/private/Repair/DropOldTables.php b/lib/private/Repair/DropOldTables.php index 15d5b9a3577..b9963b50775 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(1, "Drop old database table: $tableName"); } + $output->finishProgress(); } /** diff --git a/lib/private/repair.php b/lib/private/repair.php index 586e4e42b13..590b0bee721 100644 --- a/lib/private/repair.php +++ b/lib/private/repair.php @@ -28,7 +28,6 @@ namespace OC; -use OC\Hooks\BasicEmitter; use OC\Hooks\Emitter; use OC\Repair\AssetCache; use OC\Repair\CleanTags; @@ -51,11 +50,13 @@ use OCP\Migration\IRepairStep; use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\EventDispatcher\GenericEvent; -class Repair extends BasicEmitter implements IOutput{ +class Repair implements IOutput{ /* @var IRepairStep[] */ private $repairSteps; /** @var EventDispatcher */ private $dispatcher; + /** @var string */ + private $currentStep; /** * Creates a new repair step runner @@ -79,7 +80,8 @@ class Repair extends BasicEmitter 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) { @@ -178,10 +180,11 @@ class Repair extends BasicEmitter implements IOutput{ } /** - * {@inheritDoc} + * @param string $scope + * @param string $method + * @param array $arguments */ public function emit($scope, $method, array $arguments = []) { - parent::emit($scope, $method, $arguments); if (!is_null($this->dispatcher)) { $this->dispatcher->dispatch("$scope::$method", new GenericEvent("$scope::$method", $arguments)); @@ -206,15 +209,16 @@ class Repair extends BasicEmitter 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/private/updater.php b/lib/private/updater.php index 66f410b779f..093ebebbbe4 100644 --- a/lib/private/updater.php +++ b/lib/private/updater.php @@ -132,6 +132,8 @@ class Updater extends BasicEmitter { * @return bool true if the operation succeeded, false otherwise */ public function upgrade() { + $this->emitRepairEvents(); + $logLevel = $this->config->getSystemValue('loglevel', \OCP\Util::WARN); $this->emit('\OC\Updater', 'setDebugLogLevel', [ $logLevel, $this->logLevelNames[$logLevel] ]); $this->config->setSystemValue('loglevel', \OCP\Util::DEBUG); @@ -196,26 +198,6 @@ 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)); - }); - $repair->listen('\OC\Repair', 'info', function ($description) { - $this->emit('\OC\Updater', 'repairInfo', array($description)); - }); - $repair->listen('\OC\Repair', 'step', function ($description) { - $this->emit('\OC\Updater', 'repairStep', array($description)); - }); - } - - /** * runs the update actions in maintenance mode, does not upgrade the source files * except the main .htaccess file * @@ -245,8 +227,7 @@ class Updater extends BasicEmitter { file_put_contents($this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/.ocdata', ''); // pre-upgrade repairs - $repair = new Repair(Repair::getBeforeUpgradeRepairSteps()); - $this->emitRepairMessages($repair); + $repair = new Repair(Repair::getBeforeUpgradeRepairSteps(), \OC::$server->getEventDispatcher()); $repair->run(); // simulate DB upgrade @@ -278,8 +259,7 @@ class Updater extends BasicEmitter { } // post-upgrade repairs - $repair = new Repair(Repair::getRepairSteps()); - $this->emitRepairMessages($repair); + $repair = new Repair(Repair::getRepairSteps(), \OC::$server->getEventDispatcher()); $repair->run(); //Invalidate update feed @@ -362,7 +342,6 @@ class Updater extends BasicEmitter { * @throws NeedsUpdateException */ protected function doAppUpgrade() { - $this->emitRepairEvents(); $apps = \OC_App::getEnabledApps(); $priorityTypes = array('authentication', 'filesystem', 'logging'); $pseudoOtherType = 'other'; 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 |