protected function execute(InputInterface $input, OutputInterface $output) { $includeExpensive = $input->getOption('include-expensive'); if ($includeExpensive) { foreach ($this->repair->getExpensiveRepairSteps() as $step) { $this->repair->addStep($step); } } $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->repair->run(); $this->config->setSystemValue('maintenance', $maintenanceMode); }
public function testRunRepairStepsContinueAfterWarning() { $this->repair->addStep(new TestRepairStep(true)); $this->repair->addStep(new TestRepairStep(false)); $this->repair->run(); $this->assertEquals(array('step: Test Name', 'warning: Simulated warning', 'step: Test Name', 'info: Simulated info'), $this->outputArray); }
/** * @param array $argument * @throws \Exception * @throws \OC\NeedsUpdateException */ protected function run($argument) { if (!isset($argument['app']) || !isset($argument['step'])) { // remove the job - we can never execute it $this->jobList->remove($this, $this->argument); return; } $app = $argument['app']; try { $this->loadApp($app); } catch (NeedsUpdateException $ex) { // as long as the app is not yet done with it's offline migration // we better not start with the live migration return; } $step = $argument['step']; $repair = new Repair([], $this->dispatcher); try { $repair->addStep($step); } catch (\Exception $ex) { $this->logger->logException($ex, ['app' => 'migration']); // remove the job - we can never execute it $this->jobList->remove($this, $this->argument); return; } // execute the repair step $repair->run(); // remove the job once executed successfully $this->jobList->remove($this, $this->argument); }
protected function execute(InputInterface $input, OutputInterface $output) { $includeExpensive = $input->getOption('include-expensive'); if ($includeExpensive) { foreach ($this->repair->getExpensiveRepairSteps() as $step) { $this->repair->addStep($step); } } $apps = \OC::$server->getAppManager()->getInstalledApps(); foreach ($apps as $app) { if (!\OC_App::isEnabled($app)) { continue; } $info = \OC_App::getAppInfo($app); if (!is_array($info)) { continue; } $steps = $info['repair-steps']['post-migration']; foreach ($steps as $step) { try { $this->repair->addStep($step); } catch (Exception $ex) { $output->writeln("<error>Failed to load repair step for {$app}: {$ex->getMessage()}</error>"); } } } $maintenanceMode = $this->config->getSystemValue('maintenance', false); $this->config->setSystemValue('maintenance', true); $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); }
/** * @param string $appId * @param string[] $steps * @throws \OC\NeedsUpdateException */ public static function executeRepairSteps($appId, array $steps) { if (empty($steps)) { return; } // load the app self::loadApp($appId, false); $dispatcher = OC::$server->getEventDispatcher(); // load the steps $r = new Repair([], $dispatcher); foreach ($steps as $step) { try { $r->addStep($step); } catch (Exception $ex) { $r->emit('\\OC\\Repair', 'error', [$ex->getMessage()]); \OC::$server->getLogger()->logException($ex); } } // run the steps $r->run(); }