CleanupDirectLinksJob.php 824 B

1234567891011121314151617181920212223242526272829303132
  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. /** @var DirectMapper */
  13. private $mapper;
  14. public function __construct(ITimeFactory $timeFactory, DirectMapper $mapper) {
  15. parent::__construct($timeFactory);
  16. $this->mapper = $mapper;
  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. }