Utils: improve filewatcher

Avoid internal calls of QFileSystemEngine::fillMetaData
which are expensive and especially on Windows trow
GetFileAttributesEx can hang for seconds.
(network drive or one drive which locks files)

Task-number: QDS-8820
Change-Id: I3269ade03d1c1ed65417eebf956080414c5d087b
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Tim Jenssen
2023-01-18 18:28:22 +01:00
parent db7c1c6770
commit 8e69490dad

View File

@@ -3,6 +3,7 @@
#include "filesystemwatcher.h"
#include "globalfilechangeblocker.h"
#include "filepath.h"
#include <QDir>
#include <QFileSystemWatcher>
@@ -437,9 +438,9 @@ void FileSystemWatcher::slotDirectoryChanged(const QString &path)
}
QStringList toReadd;
const QDir dir(path);
for (const QFileInfo &entry : dir.entryInfoList(QDir::Files)) {
const QString file = entry.filePath();
const auto dir = FilePath::fromString(path);
for (const FilePath &entry : dir.dirEntries(QDir::Files)) {
const QString file = entry.toString();
if (d->m_files.contains(file))
toReadd.append(file);
}