1
0

AddCheckForUserCertificatesJob.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-License-Identifier: AGPL-3.0-or-later
  5. */
  6. namespace OC\Repair\NC21;
  7. use OC\Core\BackgroundJobs\CheckForUserCertificates;
  8. use OCP\BackgroundJob\IJobList;
  9. use OCP\IConfig;
  10. use OCP\Migration\IOutput;
  11. use OCP\Migration\IRepairStep;
  12. class AddCheckForUserCertificatesJob implements IRepairStep {
  13. /** @var IJobList */
  14. protected $jobList;
  15. /** @var IConfig */
  16. private $config;
  17. public function __construct(IConfig $config, IJobList $jobList) {
  18. $this->jobList = $jobList;
  19. $this->config = $config;
  20. }
  21. public function getName() {
  22. return 'Queue a one-time job to check for user uploaded certificates';
  23. }
  24. private function shouldRun() {
  25. $versionFromBeforeUpdate = $this->config->getSystemValueString('version', '0.0.0.0');
  26. // was added to 21.0.0.2
  27. return version_compare($versionFromBeforeUpdate, '21.0.0.2', '<');
  28. }
  29. public function run(IOutput $output) {
  30. if ($this->shouldRun()) {
  31. $this->config->setAppValue('files_external', 'user_certificate_scan', 'not-run-yet');
  32. $this->jobList->add(CheckForUserCertificates::class);
  33. }
  34. }
  35. }