2013-11-26 13:12:48 +00:00
|
|
|
<?php
|
|
|
|
/**
|
2015-02-26 10:37:37 +00:00
|
|
|
* Copyright (c) 2013 Robin Appelman <icewind@owncloud.com>
|
|
|
|
* This file is licensed under the Affero General Public License version 3 or
|
|
|
|
* later.
|
|
|
|
* See the COPYING-README file.
|
2013-11-26 13:12:48 +00:00
|
|
|
*/
|
2015-02-26 10:37:37 +00:00
|
|
|
|
2013-11-26 13:12:48 +00:00
|
|
|
namespace OC\Core\Command\Maintenance;
|
|
|
|
|
|
|
|
use Symfony\Component\Console\Command\Command;
|
|
|
|
use Symfony\Component\Console\Input\InputInterface;
|
|
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
|
|
|
|
|
|
|
class Repair extends Command {
|
|
|
|
/**
|
|
|
|
* @var \OC\Repair $repair
|
|
|
|
*/
|
|
|
|
protected $repair;
|
2014-11-18 23:25:26 +00:00
|
|
|
/** @var \OCP\IConfig */
|
|
|
|
protected $config;
|
2013-11-26 13:12:48 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param \OC\Repair $repair
|
2014-11-18 23:25:26 +00:00
|
|
|
* @param \OCP\IConfig $config
|
2013-11-26 13:12:48 +00:00
|
|
|
*/
|
2014-11-18 23:25:26 +00:00
|
|
|
public function __construct(\OC\Repair $repair, \OCP\IConfig $config) {
|
2013-11-26 13:12:48 +00:00
|
|
|
$this->repair = $repair;
|
2014-06-10 09:47:27 +00:00
|
|
|
$this->config = $config;
|
2013-11-26 13:12:48 +00:00
|
|
|
parent::__construct();
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function configure() {
|
|
|
|
$this
|
|
|
|
->setName('maintenance:repair')
|
2014-05-19 13:29:38 +00:00
|
|
|
->setDescription('repair this installation');
|
2013-11-26 13:12:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) {
|
2014-11-18 23:25:26 +00:00
|
|
|
$maintenanceMode = $this->config->getSystemValue('maintenance', false);
|
|
|
|
$this->config->setSystemValue('maintenance', true);
|
2014-03-25 11:51:16 +00:00
|
|
|
|
2013-11-26 13:12:48 +00:00
|
|
|
$this->repair->listen('\OC\Repair', 'step', function ($description) use ($output) {
|
|
|
|
$output->writeln(' - ' . $description);
|
|
|
|
});
|
2014-03-25 11:51:16 +00:00
|
|
|
$this->repair->listen('\OC\Repair', 'info', function ($description) use ($output) {
|
|
|
|
$output->writeln(' - ' . $description);
|
|
|
|
});
|
|
|
|
$this->repair->listen('\OC\Repair', 'error', function ($description) use ($output) {
|
|
|
|
$output->writeln(' - ERROR: ' . $description);
|
|
|
|
});
|
|
|
|
|
2013-11-26 13:12:48 +00:00
|
|
|
$this->repair->run();
|
2014-03-25 11:51:16 +00:00
|
|
|
|
2014-11-18 23:25:26 +00:00
|
|
|
$this->config->setSystemValue('maintenance', $maintenanceMode);
|
2013-11-26 13:12:48 +00:00
|
|
|
}
|
|
|
|
}
|