Fix date / content changed check triggering on plugin start

This commit is contained in:
WarmUpTill 2026-03-30 19:08:33 +02:00 committed by WarmUpTill
parent 7e940e515b
commit d6bf9ed101
2 changed files with 5 additions and 2 deletions

View File

@ -124,8 +124,10 @@ bool MacroConditionFile::CheckChangeContent()
SetTempVarValue("content", filedata.toStdString());
size_t newHash = strHash(filedata.toUtf8().constData());
const bool contentChanged = newHash != _lastHash;
const bool contentChanged = !_firstContentCheck &&
(newHash != _lastHash);
_lastHash = newHash;
_firstContentCheck = false;
return contentChanged;
}
@ -138,7 +140,7 @@ bool MacroConditionFile::CheckChangeDate()
QFile file(QString::fromStdString(_file));
QDateTime newLastMod = QFileInfo(file).lastModified();
SetVariableValue(newLastMod.toString().toStdString());
const bool dateChanged = _lastMod != newLastMod;
const bool dateChanged = _lastMod.isValid() && (_lastMod != newLastMod);
_lastMod = newLastMod;
SetTempVarValue("date", newLastMod.toString(Qt::ISODate).toStdString());
return dateChanged;

View File

@ -62,6 +62,7 @@ private:
Condition _condition = Condition::MATCH;
QDateTime _lastMod;
size_t _lastHash = 0;
bool _firstContentCheck = true;
std::string _lastFile;
std::string _basename;
std::string _basenameComplete;