MoveAvatars.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-License-Identifier: AGPL-3.0-or-later
  5. */
  6. namespace OC\Repair\Owncloud;
  7. use OCP\BackgroundJob\IJobList;
  8. use OCP\IConfig;
  9. use OCP\Migration\IOutput;
  10. use OCP\Migration\IRepairStep;
  11. class MoveAvatars implements IRepairStep {
  12. /** @var IJobList */
  13. private $jobList;
  14. /** @var IConfig */
  15. private $config;
  16. /**
  17. * MoveAvatars constructor.
  18. *
  19. * @param IJobList $jobList
  20. * @param IConfig $config
  21. */
  22. public function __construct(IJobList $jobList,
  23. IConfig $config) {
  24. $this->jobList = $jobList;
  25. $this->config = $config;
  26. }
  27. /**
  28. * @return string
  29. */
  30. public function getName() {
  31. return 'Add move avatar background job';
  32. }
  33. public function run(IOutput $output) {
  34. // only run once
  35. if ($this->config->getAppValue('core', 'moveavatarsdone') === 'yes') {
  36. $output->info('Repair step already executed');
  37. return;
  38. }
  39. if (!$this->config->getSystemValueBool('enable_avatars', true)) {
  40. $output->info('Avatars are disabled');
  41. } else {
  42. $output->info('Add background job');
  43. $this->jobList->add(MoveAvatarsBackgroundJob::class);
  44. // if all were done, no need to redo the repair during next upgrade
  45. $this->config->setAppValue('core', 'moveavatarsdone', 'yes');
  46. }
  47. }
  48. }