Skip to content

Commit

Permalink
Do polling based file watching for NFS on linux, resolves keepassxreb…
Browse files Browse the repository at this point in the history
  • Loading branch information
vasporig authored and droidmonkey committed Sep 26, 2018
1 parent 44c9469 commit 61d7e6b
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/gui/DatabaseWidget.cpp
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 61d7e6b

Please sign in to comment.