Skip to content

Commit

Permalink
Do polling based file watching for NFS on linux, resolves #1799
Browse files Browse the repository at this point in the history
  • Loading branch information
vasporig committed Aug 3, 2018
1 parent 07efabe commit c9208ee
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/gui/DatabaseWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1215,6 +1215,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;
}
Expand Down
4 changes: 4 additions & 0 deletions src/gui/DatabaseWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
#include <QStackedWidget>
#include <QTimer>

#ifdef Q_OS_LINUX
#include <sys/vfs.h>
#endif

#include "gui/entry/EntryModel.h"
#include "gui/MessageWidget.h"
#include "gui/csvImport/CsvImportWizard.h"
Expand Down

0 comments on commit c9208ee

Please sign in to comment.