mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-28 08:14:04 +02:00
Import: do nothing if matching last import
This commit is contained in:
parent
9c66661cdf
commit
c456f79c4c
@ -6,6 +6,7 @@ use Icinga\Module\Director\Objects\ImportSource;
|
|||||||
use Icinga\Module\Director\Import\Import;
|
use Icinga\Module\Director\Import\Import;
|
||||||
use Icinga\Exception\InvalidPropertyException;
|
use Icinga\Exception\InvalidPropertyException;
|
||||||
use Icinga\Web\Notification;
|
use Icinga\Web\Notification;
|
||||||
|
use Icinga\Web\Url;
|
||||||
|
|
||||||
class Director_ImportsourceController extends ActionController
|
class Director_ImportsourceController extends ActionController
|
||||||
{
|
{
|
||||||
@ -22,9 +23,11 @@ class Director_ImportsourceController extends ActionController
|
|||||||
public function runAction()
|
public function runAction()
|
||||||
{
|
{
|
||||||
if ($runId = Import::run($id = ImportSource::load($this->params->get('id'), $this->db()))) {
|
if ($runId = Import::run($id = ImportSource::load($this->params->get('id'), $this->db()))) {
|
||||||
Notification::success('adf' . $runId);
|
Notification::success('Import succeeded');
|
||||||
$this->redirectNow('director/list/importrun');
|
$this->redirectNow(Url::fromPath('director/importrun', array('id' => $runId)));
|
||||||
} else {
|
} else {
|
||||||
|
Notification::success('Import skipped, no changes detected');
|
||||||
|
$this->redirectNow('director/list/importrun');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
namespace Icinga\Module\Director\Import;
|
namespace Icinga\Module\Director\Import;
|
||||||
|
|
||||||
use Icinga\Module\Director\Objects\ImportSource;
|
use Icinga\Module\Director\Objects\ImportSource;
|
||||||
|
use Icinga\Module\Director\Util;
|
||||||
use Icinga\Module\Director\Web\Hook\ImportSourceHook;
|
use Icinga\Module\Director\Web\Hook\ImportSourceHook;
|
||||||
|
|
||||||
class Import
|
class Import
|
||||||
@ -84,6 +85,12 @@ continue;
|
|||||||
$rowSums = array_keys($rows);
|
$rowSums = array_keys($rows);
|
||||||
$rowset = sha1(implode(';', $rowSums), true);
|
$rowset = sha1(implode(';', $rowSums), true);
|
||||||
|
|
||||||
|
if ($this->rowSetExists($rowset)) {
|
||||||
|
if ($connection->getLatestImportedChecksum($source->id) === Util::binary2hex($rowset)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$db->beginTransaction();
|
$db->beginTransaction();
|
||||||
if (! $this->rowSetExists($rowset)) {
|
if (! $this->rowSetExists($rowset)) {
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user