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;
|
|
|
|
|
|
2023-11-23 04:22:34 -05:00
|
|
|
use OC\Lock\DBLockingProvider;
|
2022-12-05 04:13:34 -05:00
|
|
|
use OCP\AppFramework\Utility\ITimeFactory;
|
|
|
|
|
use OCP\BackgroundJob\TimedJob;
|
2025-02-03 09:34:01 -05:00
|
|
|
use OCP\Lock\ILockingProvider;
|
|
|
|
|
use OCP\Server;
|
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 {
|
|
|
|
|
/**
|
|
|
|
|
* sets the correct interval for this timed job
|
|
|
|
|
*/
|
2022-12-05 04:13:34 -05:00
|
|
|
public function __construct(ITimeFactory $time) {
|
|
|
|
|
parent::__construct($time);
|
2024-10-07 11:36:55 -04:00
|
|
|
$this->setInterval(5 * 60);
|
2016-03-04 09:42:35 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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) {
|
2025-02-03 09:34:01 -05:00
|
|
|
$lockingProvider = Server::get(ILockingProvider::class);
|
2020-04-10 08:19:56 -04:00
|
|
|
if ($lockingProvider instanceof DBLockingProvider) {
|
2016-03-04 09:42:35 -05:00
|
|
|
$lockingProvider->cleanExpiredLocks();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|