2016-09-12 10:53:31 +03:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* @copyright 2016 Roeland Jago Douma <roeland@famdouma.nl>
|
|
|
|
*
|
2017-11-06 17:56:42 +03:00
|
|
|
* @author Morris Jobke <hey@morrisjobke.de>
|
2016-09-12 10:53:31 +03:00
|
|
|
* @author Roeland Jago Douma <roeland@famdouma.nl>
|
|
|
|
*
|
|
|
|
* @license GNU AGPL version 3 or any later version
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as
|
|
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
namespace OC\Repair\NC11;
|
|
|
|
|
2016-09-14 21:15:15 +03:00
|
|
|
use OCP\BackgroundJob\IJobList;
|
2016-11-29 18:05:09 +03:00
|
|
|
use OCP\IConfig;
|
2016-09-12 10:53:31 +03:00
|
|
|
use OCP\Migration\IOutput;
|
|
|
|
use OCP\Migration\IRepairStep;
|
|
|
|
|
|
|
|
class MoveAvatars implements IRepairStep {
|
|
|
|
|
2016-09-14 21:15:15 +03:00
|
|
|
/** @var IJobList */
|
|
|
|
private $jobList;
|
2016-09-12 10:53:31 +03:00
|
|
|
|
2016-11-29 18:05:09 +03:00
|
|
|
/** @var IConfig */
|
|
|
|
private $config;
|
2016-09-12 10:53:31 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* MoveAvatars constructor.
|
|
|
|
*
|
2016-09-14 21:15:15 +03:00
|
|
|
* @param IJobList $jobList
|
2016-11-29 18:05:09 +03:00
|
|
|
* @param IConfig $config
|
2016-09-12 10:53:31 +03:00
|
|
|
*/
|
2016-09-14 21:15:15 +03:00
|
|
|
public function __construct(IJobList $jobList,
|
2016-11-29 18:05:09 +03:00
|
|
|
IConfig $config) {
|
2016-09-14 21:15:15 +03:00
|
|
|
$this->jobList = $jobList;
|
2016-11-29 18:05:09 +03:00
|
|
|
$this->config = $config;
|
2016-09-12 10:53:31 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getName() {
|
2016-11-29 18:05:09 +03:00
|
|
|
return 'Add move avatar background job';
|
2016-09-12 10:53:31 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
public function run(IOutput $output) {
|
2016-11-29 18:05:09 +03:00
|
|
|
// only run once
|
|
|
|
if ($this->config->getAppValue('core', 'moveavatarsdone') === 'yes') {
|
|
|
|
$output->info('Repair step already executed');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if ($this->config->getSystemValue('enable_avatars', true) === false) {
|
2016-09-12 10:53:31 +03:00
|
|
|
$output->info('Avatars are disabled');
|
|
|
|
} else {
|
2016-11-29 18:05:09 +03:00
|
|
|
$output->info('Add background job');
|
2016-09-14 21:15:15 +03:00
|
|
|
$this->jobList->add(MoveAvatarsBackgroundJob::class);
|
2016-11-29 18:05:09 +03:00
|
|
|
// if all were done, no need to redo the repair during next upgrade
|
|
|
|
$this->config->setAppValue('core', 'moveavatarsdone', 'yes');
|
2016-09-12 10:53:31 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|