@@ -38,120 +38,120 @@  | 
                                                    ||
| 38 | 38 | use Symfony\Component\EventDispatcher\GenericEvent;  | 
                                                        
| 39 | 39 | |
| 40 | 40 |  class Repair extends Command { | 
                                                        
| 41 | - /** @var \OC\Repair $repair */  | 
                                                        |
| 42 | - protected $repair;  | 
                                                        |
| 43 | - /** @var IConfig */  | 
                                                        |
| 44 | - protected $config;  | 
                                                        |
| 45 | - /** @var EventDispatcherInterface */  | 
                                                        |
| 46 | - private $dispatcher;  | 
                                                        |
| 47 | - /** @var ProgressBar */  | 
                                                        |
| 48 | - private $progress;  | 
                                                        |
| 49 | - /** @var OutputInterface */  | 
                                                        |
| 50 | - private $output;  | 
                                                        |
| 51 | - /** @var IAppManager */  | 
                                                        |
| 52 | - private $appManager;  | 
                                                        |
| 41 | + /** @var \OC\Repair $repair */  | 
                                                        |
| 42 | + protected $repair;  | 
                                                        |
| 43 | + /** @var IConfig */  | 
                                                        |
| 44 | + protected $config;  | 
                                                        |
| 45 | + /** @var EventDispatcherInterface */  | 
                                                        |
| 46 | + private $dispatcher;  | 
                                                        |
| 47 | + /** @var ProgressBar */  | 
                                                        |
| 48 | + private $progress;  | 
                                                        |
| 49 | + /** @var OutputInterface */  | 
                                                        |
| 50 | + private $output;  | 
                                                        |
| 51 | + /** @var IAppManager */  | 
                                                        |
| 52 | + private $appManager;  | 
                                                        |
| 53 | 53 | |
| 54 | - /**  | 
                                                        |
| 55 | - * @param \OC\Repair $repair  | 
                                                        |
| 56 | - * @param IConfig $config  | 
                                                        |
| 57 | - * @param EventDispatcherInterface $dispatcher  | 
                                                        |
| 58 | - * @param IAppManager $appManager  | 
                                                        |
| 59 | - */  | 
                                                        |
| 60 | -	public function __construct(\OC\Repair $repair, IConfig $config, EventDispatcherInterface $dispatcher, IAppManager $appManager) { | 
                                                        |
| 61 | - $this->repair = $repair;  | 
                                                        |
| 62 | - $this->config = $config;  | 
                                                        |
| 63 | - $this->dispatcher = $dispatcher;  | 
                                                        |
| 64 | - $this->appManager = $appManager;  | 
                                                        |
| 65 | - parent::__construct();  | 
                                                        |
| 66 | - }  | 
                                                        |
| 54 | + /**  | 
                                                        |
| 55 | + * @param \OC\Repair $repair  | 
                                                        |
| 56 | + * @param IConfig $config  | 
                                                        |
| 57 | + * @param EventDispatcherInterface $dispatcher  | 
                                                        |
| 58 | + * @param IAppManager $appManager  | 
                                                        |
| 59 | + */  | 
                                                        |
| 60 | +    public function __construct(\OC\Repair $repair, IConfig $config, EventDispatcherInterface $dispatcher, IAppManager $appManager) { | 
                                                        |
| 61 | + $this->repair = $repair;  | 
                                                        |
| 62 | + $this->config = $config;  | 
                                                        |
| 63 | + $this->dispatcher = $dispatcher;  | 
                                                        |
| 64 | + $this->appManager = $appManager;  | 
                                                        |
| 65 | + parent::__construct();  | 
                                                        |
| 66 | + }  | 
                                                        |
| 67 | 67 | |
| 68 | -	protected function configure() { | 
                                                        |
| 69 | - $this  | 
                                                        |
| 70 | -			->setName('maintenance:repair') | 
                                                        |
| 71 | -			->setDescription('repair this installation') | 
                                                        |
| 72 | - ->addOption(  | 
                                                        |
| 73 | - 'include-expensive',  | 
                                                        |
| 74 | - null,  | 
                                                        |
| 75 | - InputOption::VALUE_NONE,  | 
                                                        |
| 76 | - 'Use this option when you want to include resource and load expensive tasks');  | 
                                                        |
| 77 | - }  | 
                                                        |
| 68 | +    protected function configure() { | 
                                                        |
| 69 | + $this  | 
                                                        |
| 70 | +            ->setName('maintenance:repair') | 
                                                        |
| 71 | +            ->setDescription('repair this installation') | 
                                                        |
| 72 | + ->addOption(  | 
                                                        |
| 73 | + 'include-expensive',  | 
                                                        |
| 74 | + null,  | 
                                                        |
| 75 | + InputOption::VALUE_NONE,  | 
                                                        |
| 76 | + 'Use this option when you want to include resource and load expensive tasks');  | 
                                                        |
| 77 | + }  | 
                                                        |
| 78 | 78 | |
| 79 | -	protected function execute(InputInterface $input, OutputInterface $output) { | 
                                                        |
| 80 | - $repairSteps = $this->repair::getRepairSteps();  | 
                                                        |
| 79 | +    protected function execute(InputInterface $input, OutputInterface $output) { | 
                                                        |
| 80 | + $repairSteps = $this->repair::getRepairSteps();  | 
                                                        |
| 81 | 81 | |
| 82 | -		if ($input->getOption('include-expensive')) { | 
                                                        |
| 83 | - $repairSteps = array_merge($repairSteps, $this->repair::getExpensiveRepairSteps());  | 
                                                        |
| 84 | - }  | 
                                                        |
| 82 | +        if ($input->getOption('include-expensive')) { | 
                                                        |
| 83 | + $repairSteps = array_merge($repairSteps, $this->repair::getExpensiveRepairSteps());  | 
                                                        |
| 84 | + }  | 
                                                        |
| 85 | 85 | |
| 86 | -		foreach ($repairSteps as $step) { | 
                                                        |
| 87 | - $this->repair->addStep($step);  | 
                                                        |
| 88 | - }  | 
                                                        |
| 86 | +        foreach ($repairSteps as $step) { | 
                                                        |
| 87 | + $this->repair->addStep($step);  | 
                                                        |
| 88 | + }  | 
                                                        |
| 89 | 89 | |
| 90 | - $apps = $this->appManager->getInstalledApps();  | 
                                                        |
| 91 | -		foreach ($apps as $app) { | 
                                                        |
| 92 | -			if (!$this->appManager->isEnabledForUser($app)) { | 
                                                        |
| 93 | - continue;  | 
                                                        |
| 94 | - }  | 
                                                        |
| 95 | - $info = \OC_App::getAppInfo($app);  | 
                                                        |
| 96 | -			if (!is_array($info)) { | 
                                                        |
| 97 | - continue;  | 
                                                        |
| 98 | - }  | 
                                                        |
| 99 | - \OC_App::loadApp($app);  | 
                                                        |
| 100 | - $steps = $info['repair-steps']['post-migration'];  | 
                                                        |
| 101 | -			foreach ($steps as $step) { | 
                                                        |
| 102 | -				try { | 
                                                        |
| 103 | - $this->repair->addStep($step);  | 
                                                        |
| 104 | -				} catch (Exception $ex) { | 
                                                        |
| 105 | -					$output->writeln("<error>Failed to load repair step for $app: {$ex->getMessage()}</error>"); | 
                                                        |
| 106 | - }  | 
                                                        |
| 107 | - }  | 
                                                        |
| 108 | - }  | 
                                                        |
| 90 | + $apps = $this->appManager->getInstalledApps();  | 
                                                        |
| 91 | +        foreach ($apps as $app) { | 
                                                        |
| 92 | +            if (!$this->appManager->isEnabledForUser($app)) { | 
                                                        |
| 93 | + continue;  | 
                                                        |
| 94 | + }  | 
                                                        |
| 95 | + $info = \OC_App::getAppInfo($app);  | 
                                                        |
| 96 | +            if (!is_array($info)) { | 
                                                        |
| 97 | + continue;  | 
                                                        |
| 98 | + }  | 
                                                        |
| 99 | + \OC_App::loadApp($app);  | 
                                                        |
| 100 | + $steps = $info['repair-steps']['post-migration'];  | 
                                                        |
| 101 | +            foreach ($steps as $step) { | 
                                                        |
| 102 | +                try { | 
                                                        |
| 103 | + $this->repair->addStep($step);  | 
                                                        |
| 104 | +                } catch (Exception $ex) { | 
                                                        |
| 105 | +                    $output->writeln("<error>Failed to load repair step for $app: {$ex->getMessage()}</error>"); | 
                                                        |
| 106 | + }  | 
                                                        |
| 107 | + }  | 
                                                        |
| 108 | + }  | 
                                                        |
| 109 | 109 | |
| 110 | -		$maintenanceMode = $this->config->getSystemValueBool('maintenance'); | 
                                                        |
| 111 | -		$this->config->setSystemValue('maintenance', true); | 
                                                        |
| 110 | +        $maintenanceMode = $this->config->getSystemValueBool('maintenance'); | 
                                                        |
| 111 | +        $this->config->setSystemValue('maintenance', true); | 
                                                        |
| 112 | 112 | |
| 113 | - $this->progress = new ProgressBar($output);  | 
                                                        |
| 114 | - $this->output = $output;  | 
                                                        |
| 115 | -		$this->dispatcher->addListener('\OC\Repair::startProgress', [$this, 'handleRepairFeedBack']); | 
                                                        |
| 116 | -		$this->dispatcher->addListener('\OC\Repair::advance', [$this, 'handleRepairFeedBack']); | 
                                                        |
| 117 | -		$this->dispatcher->addListener('\OC\Repair::finishProgress', [$this, 'handleRepairFeedBack']); | 
                                                        |
| 118 | -		$this->dispatcher->addListener('\OC\Repair::step', [$this, 'handleRepairFeedBack']); | 
                                                        |
| 119 | -		$this->dispatcher->addListener('\OC\Repair::info', [$this, 'handleRepairFeedBack']); | 
                                                        |
| 120 | -		$this->dispatcher->addListener('\OC\Repair::warning', [$this, 'handleRepairFeedBack']); | 
                                                        |
| 121 | -		$this->dispatcher->addListener('\OC\Repair::error', [$this, 'handleRepairFeedBack']); | 
                                                        |
| 113 | + $this->progress = new ProgressBar($output);  | 
                                                        |
| 114 | + $this->output = $output;  | 
                                                        |
| 115 | +        $this->dispatcher->addListener('\OC\Repair::startProgress', [$this, 'handleRepairFeedBack']); | 
                                                        |
| 116 | +        $this->dispatcher->addListener('\OC\Repair::advance', [$this, 'handleRepairFeedBack']); | 
                                                        |
| 117 | +        $this->dispatcher->addListener('\OC\Repair::finishProgress', [$this, 'handleRepairFeedBack']); | 
                                                        |
| 118 | +        $this->dispatcher->addListener('\OC\Repair::step', [$this, 'handleRepairFeedBack']); | 
                                                        |
| 119 | +        $this->dispatcher->addListener('\OC\Repair::info', [$this, 'handleRepairFeedBack']); | 
                                                        |
| 120 | +        $this->dispatcher->addListener('\OC\Repair::warning', [$this, 'handleRepairFeedBack']); | 
                                                        |
| 121 | +        $this->dispatcher->addListener('\OC\Repair::error', [$this, 'handleRepairFeedBack']); | 
                                                        |
| 122 | 122 | |
| 123 | - $this->repair->run();  | 
                                                        |
| 123 | + $this->repair->run();  | 
                                                        |
| 124 | 124 | |
| 125 | -		$this->config->setSystemValue('maintenance', $maintenanceMode); | 
                                                        |
| 126 | - }  | 
                                                        |
| 125 | +        $this->config->setSystemValue('maintenance', $maintenanceMode); | 
                                                        |
| 126 | + }  | 
                                                        |
| 127 | 127 | |
| 128 | -	public function handleRepairFeedBack($event) { | 
                                                        |
| 129 | -		if (!$event instanceof GenericEvent) { | 
                                                        |
| 130 | - return;  | 
                                                        |
| 131 | - }  | 
                                                        |
| 132 | -		switch ($event->getSubject()) { | 
                                                        |
| 133 | - case '\OC\Repair::startProgress':  | 
                                                        |
| 134 | - $this->progress->start($event->getArgument(0));  | 
                                                        |
| 135 | - break;  | 
                                                        |
| 136 | - case '\OC\Repair::advance':  | 
                                                        |
| 137 | - $this->progress->advance($event->getArgument(0));  | 
                                                        |
| 138 | - break;  | 
                                                        |
| 139 | - case '\OC\Repair::finishProgress':  | 
                                                        |
| 140 | - $this->progress->finish();  | 
                                                        |
| 141 | -				$this->output->writeln(''); | 
                                                        |
| 142 | - break;  | 
                                                        |
| 143 | - case '\OC\Repair::step':  | 
                                                        |
| 144 | -				$this->output->writeln(' - ' . $event->getArgument(0)); | 
                                                        |
| 145 | - break;  | 
                                                        |
| 146 | - case '\OC\Repair::info':  | 
                                                        |
| 147 | -				$this->output->writeln('     - ' . $event->getArgument(0)); | 
                                                        |
| 148 | - break;  | 
                                                        |
| 149 | - case '\OC\Repair::warning':  | 
                                                        |
| 150 | -				$this->output->writeln('     - WARNING: ' . $event->getArgument(0)); | 
                                                        |
| 151 | - break;  | 
                                                        |
| 152 | - case '\OC\Repair::error':  | 
                                                        |
| 153 | -				$this->output->writeln('     - ERROR: ' . $event->getArgument(0)); | 
                                                        |
| 154 | - break;  | 
                                                        |
| 155 | - }  | 
                                                        |
| 156 | - }  | 
                                                        |
| 128 | +    public function handleRepairFeedBack($event) { | 
                                                        |
| 129 | +        if (!$event instanceof GenericEvent) { | 
                                                        |
| 130 | + return;  | 
                                                        |
| 131 | + }  | 
                                                        |
| 132 | +        switch ($event->getSubject()) { | 
                                                        |
| 133 | + case '\OC\Repair::startProgress':  | 
                                                        |
| 134 | + $this->progress->start($event->getArgument(0));  | 
                                                        |
| 135 | + break;  | 
                                                        |
| 136 | + case '\OC\Repair::advance':  | 
                                                        |
| 137 | + $this->progress->advance($event->getArgument(0));  | 
                                                        |
| 138 | + break;  | 
                                                        |
| 139 | + case '\OC\Repair::finishProgress':  | 
                                                        |
| 140 | + $this->progress->finish();  | 
                                                        |
| 141 | +                $this->output->writeln(''); | 
                                                        |
| 142 | + break;  | 
                                                        |
| 143 | + case '\OC\Repair::step':  | 
                                                        |
| 144 | +                $this->output->writeln(' - ' . $event->getArgument(0)); | 
                                                        |
| 145 | + break;  | 
                                                        |
| 146 | + case '\OC\Repair::info':  | 
                                                        |
| 147 | +                $this->output->writeln('     - ' . $event->getArgument(0)); | 
                                                        |
| 148 | + break;  | 
                                                        |
| 149 | + case '\OC\Repair::warning':  | 
                                                        |
| 150 | +                $this->output->writeln('     - WARNING: ' . $event->getArgument(0)); | 
                                                        |
| 151 | + break;  | 
                                                        |
| 152 | + case '\OC\Repair::error':  | 
                                                        |
| 153 | +                $this->output->writeln('     - ERROR: ' . $event->getArgument(0)); | 
                                                        |
| 154 | + break;  | 
                                                        |
| 155 | + }  | 
                                                        |
| 156 | + }  | 
                                                        |
| 157 | 157 | }  |