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