CleanupFileLocks.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  6. * @author Max Kovalenko <mxss1998@yandex.ru>
  7. * @author Morris Jobke <hey@morrisjobke.de>
  8. *
  9. * @license AGPL-3.0
  10. *
  11. * This code is free software: you can redistribute it and/or modify
  12. * it under the terms of the GNU Affero General Public License, version 3,
  13. * as published by the Free Software Foundation.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU Affero General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Affero General Public License, version 3,
  21. * along with this program. If not, see <http://www.gnu.org/licenses/>
  22. *
  23. */
  24. namespace OCA\Files\BackgroundJob;
  25. use OC\BackgroundJob\TimedJob;
  26. use OC\Lock\DBLockingProvider;
  27. /**
  28. * Clean up all file locks that are expired for the DB file locking provider
  29. */
  30. class CleanupFileLocks extends TimedJob {
  31. /**
  32. * Default interval in minutes
  33. *
  34. * @var int $defaultIntervalMin
  35. **/
  36. protected $defaultIntervalMin = 5;
  37. /**
  38. * sets the correct interval for this timed job
  39. */
  40. public function __construct() {
  41. $this->interval = $this->defaultIntervalMin * 60;
  42. }
  43. /**
  44. * Makes the background job do its work
  45. *
  46. * @param array $argument unused argument
  47. * @throws \Exception
  48. */
  49. public function run($argument) {
  50. $lockingProvider = \OC::$server->getLockingProvider();
  51. if ($lockingProvider instanceof DBLockingProvider) {
  52. $lockingProvider->cleanExpiredLocks();
  53. }
  54. }
  55. }