2016-03-04 09:42:35 -05:00
|
|
|
<?php
|
2024-05-28 10:42:42 -04:00
|
|
|
|
2016-03-04 09:42:35 -05:00
|
|
|
/**
|
2024-05-28 10:42:42 -04:00
|
|
|
* SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
|
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
2016-03-04 09:42:35 -05:00
|
|
|
*/
|
|
|
|
|
namespace OCA\Files\BackgroundJob;
|
|
|
|
|
|
|
|
|
|
use OC\Lock\DBLockingProvider;
|
2022-12-05 04:13:34 -05:00
|
|
|
use OCP\AppFramework\Utility\ITimeFactory;
|
|
|
|
|
use OCP\BackgroundJob\TimedJob;
|
2016-03-04 09:42:35 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Clean up all file locks that are expired for the DB file locking provider
|
|
|
|
|
*/
|
|
|
|
|
class CleanupFileLocks extends TimedJob {
|
|
|
|
|
/**
|
|
|
|
|
* Default interval in minutes
|
|
|
|
|
*
|
|
|
|
|
* @var int $defaultIntervalMin
|
|
|
|
|
**/
|
|
|
|
|
protected $defaultIntervalMin = 5;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* sets the correct interval for this timed job
|
|
|
|
|
*/
|
2022-12-05 04:13:34 -05:00
|
|
|
public function __construct(ITimeFactory $time) {
|
|
|
|
|
parent::__construct($time);
|
|
|
|
|
|
2016-03-04 09:42:35 -05:00
|
|
|
$this->interval = $this->defaultIntervalMin * 60;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Makes the background job do its work
|
|
|
|
|
*
|
|
|
|
|
* @param array $argument unused argument
|
2019-05-27 01:54:09 -04:00
|
|
|
* @throws \Exception
|
2016-03-04 09:42:35 -05:00
|
|
|
*/
|
|
|
|
|
public function run($argument) {
|
|
|
|
|
$lockingProvider = \OC::$server->getLockingProvider();
|
|
|
|
|
if ($lockingProvider instanceof DBLockingProvider) {
|
|
|
|
|
$lockingProvider->cleanExpiredLocks();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|