IcingaConfig: separate modification check from store

This commit is contained in:
Thomas Gelf 2015-11-03 09:10:34 +01:00
parent bf7001510f
commit e02e61abd4

View File

@ -89,17 +89,30 @@ class IcingaConfig
return $config->storeIfModified(); return $config->storeIfModified();
} }
protected function storeIfModified() protected function hasBeenModified()
{ {
$this->generateFromDb(); $this->generateFromDb();
$this->collectExtraFiles(); $this->collectExtraFiles();
$checksum = $this->calculateChecksum(); $checksum = $this->calculateChecksum();
$exists = $this->db->fetchOne( $exists = $this->db->fetchOne(
$this->db->select()->from(self::$table, 'COUNT(*)')->where('checksum = ?', $this->dbBin($checksum)) $this->db->select()->from(
self::$table,
'COUNT(*)'
)->where(
'checksum = ?',
$this->dbBin($checksum)
)
); );
if ((int) $exists === 0) {
return (int) $exists === 0;
}
protected function storeIfModified()
{
if ($this->hasBeenModified()) {
$this->store(); $this->store();
} }
return $this; return $this;
} }