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\Exception\InvalidPropertyException;
|
||||
use Icinga\Web\Notification;
|
||||
use Icinga\Web\Url;
|
||||
|
||||
class Director_ImportsourceController extends ActionController
|
||||
{
|
||||
|
@ -22,9 +23,11 @@ class Director_ImportsourceController extends ActionController
|
|||
public function runAction()
|
||||
{
|
||||
if ($runId = Import::run($id = ImportSource::load($this->params->get('id'), $this->db()))) {
|
||||
Notification::success('adf' . $runId);
|
||||
$this->redirectNow('director/list/importrun');
|
||||
Notification::success('Import succeeded');
|
||||
$this->redirectNow(Url::fromPath('director/importrun', array('id' => $runId)));
|
||||
} else {
|
||||
Notification::success('Import skipped, no changes detected');
|
||||
$this->redirectNow('director/list/importrun');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace Icinga\Module\Director\Import;
|
||||
|
||||
use Icinga\Module\Director\Objects\ImportSource;
|
||||
use Icinga\Module\Director\Util;
|
||||
use Icinga\Module\Director\Web\Hook\ImportSourceHook;
|
||||
|
||||
class Import
|
||||
|
@ -84,6 +85,12 @@ continue;
|
|||
$rowSums = array_keys($rows);
|
||||
$rowset = sha1(implode(';', $rowSums), true);
|
||||
|
||||
if ($this->rowSetExists($rowset)) {
|
||||
if ($connection->getLatestImportedChecksum($source->id) === Util::binary2hex($rowset)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$db->beginTransaction();
|
||||
if (! $this->rowSetExists($rowset)) {
|
||||
|
||||
|
|
Loading…
Reference in New Issue