2020-12-07 08:30:08 -05:00
|
|
|
<?php
|
2025-06-30 09:04:05 -04:00
|
|
|
|
2026-02-09 04:53:58 -05:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
2020-12-07 08:30:08 -05:00
|
|
|
/**
|
2024-05-23 03:26:56 -04:00
|
|
|
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
2020-12-07 08:30:08 -05:00
|
|
|
*/
|
|
|
|
|
namespace OC\Repair\Owncloud;
|
|
|
|
|
|
|
|
|
|
use OCP\BackgroundJob\IJobList;
|
|
|
|
|
use OCP\IConfig;
|
|
|
|
|
use OCP\Migration\IOutput;
|
|
|
|
|
use OCP\Migration\IRepairStep;
|
|
|
|
|
|
|
|
|
|
class MoveAvatars implements IRepairStep {
|
2025-11-17 09:32:54 -05:00
|
|
|
public function __construct(
|
2025-11-24 03:17:34 -05:00
|
|
|
private readonly IJobList $jobList,
|
|
|
|
|
private readonly IConfig $config,
|
2025-11-17 09:32:54 -05:00
|
|
|
) {
|
2020-12-07 08:30:08 -05:00
|
|
|
}
|
|
|
|
|
|
2025-11-24 03:17:34 -05:00
|
|
|
public function getName(): string {
|
2020-12-07 08:30:08 -05:00
|
|
|
return 'Add move avatar background job';
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-24 03:17:34 -05:00
|
|
|
public function run(IOutput $output): void {
|
2020-12-07 08:30:08 -05:00
|
|
|
// only run once
|
|
|
|
|
if ($this->config->getAppValue('core', 'moveavatarsdone') === 'yes') {
|
|
|
|
|
$output->info('Repair step already executed');
|
|
|
|
|
return;
|
|
|
|
|
}
|
2023-04-05 06:50:08 -04:00
|
|
|
if (!$this->config->getSystemValueBool('enable_avatars', true)) {
|
2020-12-07 08:30:08 -05:00
|
|
|
$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');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|