]> source.dussan.org Git - nextcloud-server.git/commitdiff
make chunksize (used to check for gone LDAP users) configurable 18055/head
authorArthur Schiwon <blizzz@arthur-schiwon.de>
Tue, 19 Nov 2019 16:56:04 +0000 (17:56 +0100)
committerBackportbot <backportbot-noreply@rullzer.com>
Thu, 21 Nov 2019 10:07:30 +0000 (10:07 +0000)
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
apps/user_ldap/lib/Jobs/CleanUp.php

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