1
0

CleanPreviews.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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\IUser;
  10. use OCP\IUserManager;
  11. use OCP\Migration\IOutput;
  12. use OCP\Migration\IRepairStep;
  13. class CleanPreviews implements IRepairStep {
  14. /** @var IJobList */
  15. private $jobList;
  16. /** @var IUserManager */
  17. private $userManager;
  18. /** @var IConfig */
  19. private $config;
  20. /**
  21. * MoveAvatars constructor.
  22. *
  23. * @param IJobList $jobList
  24. * @param IUserManager $userManager
  25. * @param IConfig $config
  26. */
  27. public function __construct(IJobList $jobList,
  28. IUserManager $userManager,
  29. IConfig $config) {
  30. $this->jobList = $jobList;
  31. $this->userManager = $userManager;
  32. $this->config = $config;
  33. }
  34. /**
  35. * @return string
  36. */
  37. public function getName() {
  38. return 'Add preview cleanup background jobs';
  39. }
  40. public function run(IOutput $output) {
  41. if (!$this->config->getAppValue('core', 'previewsCleanedUp', false)) {
  42. $this->userManager->callForSeenUsers(function (IUser $user) {
  43. $this->jobList->add(CleanPreviewsBackgroundJob::class, ['uid' => $user->getUID()]);
  44. });
  45. $this->config->setAppValue('core', 'previewsCleanedUp', '1');
  46. }
  47. }
  48. }