Completed
Push — stable8.2 ( bf9be4...0c03e7 )
by
unknown
10:30
created

CleanupFileLocks::run()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

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