core: hash scanned files and don't trigger a reload if matching

Nix builds often trip QFileSystemWatcher, causing random reloads.
This commit is contained in:
outfoxxed 2026-03-11 19:45:14 -07:00
parent bd62179277
commit 9a9c605250
No known key found for this signature in database
GPG key ID: 4C88A185FB89301E
4 changed files with 48 additions and 11 deletions

View file

@ -209,6 +209,8 @@ bool EngineGeneration::setExtraWatchedFiles(const QVector<QString>& files) {
for (const auto& file: files) {
if (!this->scanner.scannedFiles.contains(file)) {
this->extraWatchedFiles.append(file);
QByteArray data;
this->scanner.readAndHashFile(file, data);
}
}
@ -229,6 +231,11 @@ void EngineGeneration::onFileChanged(const QString& name) {
auto fileInfo = QFileInfo(name);
if (fileInfo.isFile() && fileInfo.size() == 0) return;
if (!this->scanner.hasFileContentChanged(name)) {
qCDebug(logQmlScanner) << "Ignoring file change with unchanged content:" << name;
return;
}
emit this->filesChanged();
}
}
@ -237,6 +244,11 @@ void EngineGeneration::onDirectoryChanged() {
// try to find any files that were just deleted from a replace operation
for (auto& file: this->deletedWatchedFiles) {
if (QFileInfo(file).exists()) {
if (!this->scanner.hasFileContentChanged(file)) {
qCDebug(logQmlScanner) << "Ignoring restored file with unchanged content:" << file;
continue;
}
emit this->filesChanged();
break;
}