Do polling based file watching for NFS on linux, resolves #1799

This commit is contained in:
vasporig 2018-07-31 16:10:47 +01:00 committed by Jonathan White
parent 44c9469221
commit 61d7e6bc6c

View File

@ -58,6 +58,10 @@
#include "config-keepassx.h"
#ifdef Q_OS_LINUX
#include <sys/vfs.h>
#endif
#ifdef WITH_XC_SSHAGENT
#include "sshagent/SSHAgent.h"
#endif
@ -1173,6 +1177,21 @@ void DatabaseWidget::updateFilePath(const QString& filePath)
m_fileWatcher.removePath(m_filePath);
}
#if defined(Q_OS_LINUX)
struct statfs statfsBuf;
bool forcePolling = false;
const auto NFS_SUPER_MAGIC = 0x6969;
if (!statfs(filePath.toLocal8Bit().constData(), &statfsBuf)) {
forcePolling = (statfsBuf.f_type == NFS_SUPER_MAGIC);
} else {
// if we can't get the fs type let's fall back to polling
forcePolling = true;
}
auto objectName = forcePolling ? QLatin1String("_qt_autotest_force_engine_poller") : QLatin1String("");
m_fileWatcher.setObjectName(objectName);
#endif
m_fileWatcher.addPath(filePath);
m_filePath = filePath;
m_db->setFilePath(filePath);