1
0

CleanupFileLocks.php 945 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
  5. * SPDX-License-Identifier: AGPL-3.0-only
  6. */
  7. namespace OCA\Files\BackgroundJob;
  8. use OC\Lock\DBLockingProvider;
  9. use OCP\AppFramework\Utility\ITimeFactory;
  10. use OCP\BackgroundJob\TimedJob;
  11. /**
  12. * Clean up all file locks that are expired for the DB file locking provider
  13. */
  14. class CleanupFileLocks extends TimedJob {
  15. /**
  16. * sets the correct interval for this timed job
  17. */
  18. public function __construct(ITimeFactory $time) {
  19. parent::__construct($time);
  20. $this->setInterval(5 * 60);
  21. }
  22. /**
  23. * Makes the background job do its work
  24. *
  25. * @param array $argument unused argument
  26. * @throws \Exception
  27. */
  28. public function run($argument) {
  29. $lockingProvider = \OC::$server->getLockingProvider();
  30. if ($lockingProvider instanceof DBLockingProvider) {
  31. $lockingProvider->cleanExpiredLocks();
  32. }
  33. }
  34. }