mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-30 17:24:18 +02:00
IcingaConfig: support the same file content twice
This commit is contained in:
parent
6f2bd88069
commit
1520d6fbf6
@ -227,6 +227,7 @@ class IcingaConfig
|
||||
}
|
||||
|
||||
$missing = array_diff($this->getFilesChecksums(), $existing);
|
||||
$stored = array();
|
||||
|
||||
/** @var IcingaConfigFile $file */
|
||||
foreach ($this->files as $name => $file) {
|
||||
@ -235,6 +236,12 @@ class IcingaConfig
|
||||
continue;
|
||||
}
|
||||
|
||||
if (array_key_exists($checksum, $stored)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$stored[$checksum] = true;
|
||||
|
||||
$this->db->insert(
|
||||
$fileTable,
|
||||
array(
|
||||
|
@ -11,6 +11,8 @@ class Sync
|
||||
{
|
||||
protected $rule;
|
||||
|
||||
protected $sources;
|
||||
|
||||
protected $modify = array();
|
||||
|
||||
protected $remove = array();
|
||||
@ -205,17 +207,22 @@ class Sync
|
||||
return preg_replace_callback('/\${([A-Za-z0-9\._-]+)}/', $func, $string);
|
||||
}
|
||||
|
||||
protected function perpareImportSources()
|
||||
/**
|
||||
* Instantiates all related ImportSource objects
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function prepareRelatedImportSources()
|
||||
{
|
||||
$sources = array();
|
||||
$this->sources = array();
|
||||
foreach ($this->syncProperties as $p) {
|
||||
$sourceId = $p->source_id;
|
||||
if (! array_key_exists($sourceId, $sources)) {
|
||||
$sources[$sourceId] = ImportSource::load($sourceId, $this->db);
|
||||
$id = $p->source_id;
|
||||
if (! array_key_exists($id, $sources)) {
|
||||
$this->sources[$id] = ImportSource::load($id, $this->db);
|
||||
}
|
||||
}
|
||||
|
||||
return $sources;
|
||||
return $this->sources;
|
||||
}
|
||||
|
||||
protected function prepareSourceColumns()
|
||||
@ -438,7 +445,7 @@ class Sync
|
||||
protected function prepare()
|
||||
{
|
||||
$rule = $this->rule;
|
||||
$sources = $this->perpareImportSources();
|
||||
$sources = $this->prepareRelatedImportSources();
|
||||
$imported = $this->fetchImportedData($sources);
|
||||
|
||||
// TODO: Make object_type (template, object...) and object_name mandatory?
|
||||
|
Loading…
x
Reference in New Issue
Block a user