Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Execute MoveAvatars repair step only once #2405

Merged
merged 1 commit into from
Nov 30, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/private/Repair.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public static function getRepairSteps() {
new MoveUpdaterStepFile(\OC::$server->getConfig()),
new MoveAvatars(
\OC::$server->getJobList(),
\OC::$server->getSystemConfig()
\OC::$server->getConfig()
),
];
}
Expand Down
24 changes: 16 additions & 8 deletions lib/private/Repair/NC11/MoveAvatars.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
*/
namespace OC\Repair\NC11;

use OC\SystemConfig;
use OCP\BackgroundJob\IJobList;
use OCP\IConfig;
use OCP\Migration\IOutput;
use OCP\Migration\IRepairStep;

Expand All @@ -32,33 +32,41 @@ class MoveAvatars implements IRepairStep {
/** @var IJobList */
private $jobList;

/** @var SystemConfig */
private $systemConfig;
/** @var IConfig */
private $config;

/**
* MoveAvatars constructor.
*
* @param IJobList $jobList
* @param SystemConfig $systemConfig
* @param IConfig $config
*/
public function __construct(IJobList $jobList,
SystemConfig $systemConfig) {
IConfig $config) {
$this->jobList = $jobList;
$this->systemConfig = $systemConfig;
$this->config = $config;
}

/**
* @return string
*/
public function getName() {
return 'Add mover avatar background job';
return 'Add move avatar background job';
}

public function run(IOutput $output) {
if ($this->systemConfig->getValue('enable_avatars', true) === false) {
// 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) {
$output->info('Avatars are disabled');
} else {
$output->info('Add background job');
$this->jobList->add(MoveAvatarsBackgroundJob::class);
// if all were done, no need to redo the repair during next upgrade
$this->config->setAppValue('core', 'moveavatarsdone', 'yes');
}
}
}