CleanupDirectLinksJob.php 768 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCA\DAV\BackgroundJob;
  8. use OCA\DAV\Db\DirectMapper;
  9. use OCP\AppFramework\Utility\ITimeFactory;
  10. use OCP\BackgroundJob\TimedJob;
  11. class CleanupDirectLinksJob extends TimedJob {
  12. public function __construct(
  13. ITimeFactory $timeFactory,
  14. private DirectMapper $mapper,
  15. ) {
  16. parent::__construct($timeFactory);
  17. // Run once a day at off-peak time
  18. $this->setInterval(24 * 60 * 60);
  19. $this->setTimeSensitivity(self::TIME_INSENSITIVE);
  20. }
  21. protected function run($argument) {
  22. // Delete all shares expired 24 hours ago
  23. $this->mapper->deleteExpired($this->time->getTime() - 60 * 60 * 24);
  24. }
  25. }