make chunksize (used to check for gone LDAP users) configurable

Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
This commit is contained in:
Arthur Schiwon 2019-11-19 17:56:04 +01:00 committed by Roeland Jago Douma
parent 2b2626566c
commit f990620e6b
No known key found for this signature in database
GPG Key ID: F941078878347C0C
1 changed files with 9 additions and 6 deletions

View File

@ -44,7 +44,7 @@ use OCA\User_LDAP\User\DeletedUsersIndex;
*/ */
class CleanUp extends TimedJob { class CleanUp extends TimedJob {
/** @var int $limit amount of users that should be checked per run */ /** @var int $limit amount of users that should be checked per run */
protected $limit = 50; protected $limit;
/** @var int $defaultIntervalMin default interval in minutes */ /** @var int $defaultIntervalMin default interval in minutes */
protected $defaultIntervalMin = 51; protected $defaultIntervalMin = 51;
@ -61,10 +61,10 @@ class CleanUp extends TimedJob {
/** @var Helper $ldapHelper */ /** @var Helper $ldapHelper */
protected $ldapHelper; protected $ldapHelper;
/** @var \OCA\User_LDAP\Mapping\UserMapping */ /** @var UserMapping */
protected $mapping; protected $mapping;
/** @var \OCA\User_LDAP\User\DeletedUsersIndex */ /** @var DeletedUsersIndex */
protected $dui; protected $dui;
public function __construct() { public function __construct() {
@ -138,7 +138,7 @@ class CleanUp extends TimedJob {
if(!$this->isCleanUpAllowed()) { if(!$this->isCleanUpAllowed()) {
return; return;
} }
$users = $this->mapping->getList($this->getOffset(), $this->limit); $users = $this->mapping->getList($this->getOffset(), $this->getChunkSize());
if(!is_array($users)) { if(!is_array($users)) {
//something wrong? Let's start from the beginning next time and //something wrong? Let's start from the beginning next time and
//abort //abort
@ -156,7 +156,7 @@ class CleanUp extends TimedJob {
* @return bool * @return bool
*/ */
public function isOffsetResetNecessary($resultCount) { public function isOffsetResetNecessary($resultCount) {
return $resultCount < $this->limit; return $resultCount < $this->getChunkSize();
} }
/** /**
@ -222,7 +222,7 @@ class CleanUp extends TimedJob {
*/ */
public function setOffset($reset = false) { public function setOffset($reset = false) {
$newOffset = $reset ? 0 : $newOffset = $reset ? 0 :
$this->getOffset() + $this->limit; $this->getOffset() + $this->getChunkSize();
$this->ocConfig->setAppValue('user_ldap', 'cleanUpJobOffset', $newOffset); $this->ocConfig->setAppValue('user_ldap', 'cleanUpJobOffset', $newOffset);
} }
@ -231,6 +231,9 @@ class CleanUp extends TimedJob {
* @return int * @return int
*/ */
public function getChunkSize() { public function getChunkSize() {
if($this->limit === null) {
$this->limit = (int)$this->ocConfig->getAppValue('user_ldap', 'cleanUpJobChunkSize', 50);
}
return $this->limit; return $this->limit;
} }