Skip to content

Commit 3403754

Browse files
committed
make chunksize (used to check for gone LDAP users) configurable
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
1 parent 9707fcf commit 3403754

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

apps/user_ldap/lib/Jobs/CleanUp.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
*/
4545
class CleanUp extends TimedJob {
4646
/** @var int $limit amount of users that should be checked per run */
47-
protected $limit = 50;
47+
protected $limit;
4848

4949
/** @var int $defaultIntervalMin default interval in minutes */
5050
protected $defaultIntervalMin = 51;
@@ -61,10 +61,10 @@ class CleanUp extends TimedJob {
6161
/** @var Helper $ldapHelper */
6262
protected $ldapHelper;
6363

64-
/** @var \OCA\User_LDAP\Mapping\UserMapping */
64+
/** @var UserMapping */
6565
protected $mapping;
6666

67-
/** @var \OCA\User_LDAP\User\DeletedUsersIndex */
67+
/** @var DeletedUsersIndex */
6868
protected $dui;
6969

7070
public function __construct() {
@@ -138,7 +138,7 @@ public function run($argument) {
138138
if(!$this->isCleanUpAllowed()) {
139139
return;
140140
}
141-
$users = $this->mapping->getList($this->getOffset(), $this->limit);
141+
$users = $this->mapping->getList($this->getOffset(), $this->getChunkSize());
142142
if(!is_array($users)) {
143143
//something wrong? Let's start from the beginning next time and
144144
//abort
@@ -156,7 +156,7 @@ public function run($argument) {
156156
* @return bool
157157
*/
158158
public function isOffsetResetNecessary($resultCount) {
159-
return $resultCount < $this->limit;
159+
return $resultCount < $this->getChunkSize();
160160
}
161161

162162
/**
@@ -222,7 +222,7 @@ private function getOffset() {
222222
*/
223223
public function setOffset($reset = false) {
224224
$newOffset = $reset ? 0 :
225-
$this->getOffset() + $this->limit;
225+
$this->getOffset() + $this->getChunkSize();
226226
$this->ocConfig->setAppValue('user_ldap', 'cleanUpJobOffset', $newOffset);
227227
}
228228

@@ -231,6 +231,9 @@ public function setOffset($reset = false) {
231231
* @return int
232232
*/
233233
public function getChunkSize() {
234+
if($this->limit === null) {
235+
$this->limit = (int)$this->ocConfig->getAppValue('user_ldap', 'cleanUpJobChunkSize', 50);
236+
}
234237
return $this->limit;
235238
}
236239

0 commit comments

Comments
 (0)