[icinga-checkins] icinga.org: icingaweb2-module-director/master: Sync: only return modified objects

git at icinga.org git at icinga.org
Tue Feb 23 03:15:19 CET 2016


Module: icingaweb2-module-director
Branch: master
Commit: a5b7e06ba24b4efd1c87515d9690d20cda894c8d
URL:    https://git.icinga.org/?p=icingaweb2-module-director.git;a=commit;h=a5b7e06ba24b4efd1c87515d9690d20cda894c8d

Author: Thomas Gelf <thomas at gelf.net>
Date:   Mon Feb 22 11:01:37 2016 +0100

Sync: only return modified objects

---

 library/Director/Import/Sync.php |   21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/library/Director/Import/Sync.php b/library/Director/Import/Sync.php
index 8796e47..facebf0 100644
--- a/library/Director/Import/Sync.php
+++ b/library/Director/Import/Sync.php
@@ -415,18 +415,27 @@ class Sync
         }
 
         $objectKey = $rule->object_type === 'datalistEntry' ? 'entry_name' : 'object_name';
+        $noAction = array();
+
         foreach ($objects as $key => $object) {
 
-            if ($object->hasBeenLoadedFromDb() && $rule->purge_existing === 'y') {
-                if (! array_key_exists($key, $newObjects)) {
-                    $object->markForRemoval();
+            if (array_key_exists($key, $newObjects)) {
+                // Stats?
 
-                    // TODO: this is for stats, preview, summary:
-                    // $this->remove[] = $object;
-                }
+            } elseif ($object->hasBeenLoadedFromDb() && $rule->purge_existing === 'y') {
+                $object->markForRemoval();
+
+                // TODO: this is for stats, preview, summary:
+                // $this->remove[] = $object;
+            } else {
+                $noAction[] = $key;
             }
         }
 
+        foreach ($noAction as $key) {
+            unset($objects[$key]);
+        }
+
         return $objects;
     }
 



More information about the icinga-checkins mailing list