From a9ba0a317c0638fadb22765e149d79d03030c23c Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Tue, 2 Feb 2016 14:26:10 -0500 Subject: [PATCH] Make sure the event file watcher checks for new watched files on a more regular basis. This will check every time a client asks for the latest logs, and will automatically load/parse any new file which appears. --- src/server/EventWatcher.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/server/EventWatcher.cpp b/src/server/EventWatcher.cpp index 0a8927f..8775d80 100644 --- a/src/server/EventWatcher.cpp +++ b/src/server/EventWatcher.cpp @@ -46,6 +46,7 @@ EventWatcher::EVENT_TYPE EventWatcher::typeFromString(QString typ){ } QJsonValue EventWatcher::lastEvent(EVENT_TYPE type){ + CheckLogFiles(); if(HASH.contains(type)){ return HASH.value(type); } else{ qDebug() << "No saved event:" << type; return QJsonValue(); } } @@ -124,15 +125,15 @@ void EventWatcher::WatcherUpdate(const QString &path){ watcher->removePath(path); } } - CheckLogFiles(); //check for any other missing files + QTimer::singleShot(10,this, SLOT(CheckLogFiles()) ); //check for any other missing files } void EventWatcher::CheckLogFiles(){ //Make sure all the proper files are being watched QStringList watched; watched << watcher->files() << watcher->directories(); - if(!watched.contains(LPLOG) && QFile::exists(LPLOG)){ watcher->addPath(LPLOG); } - if(!watched.contains(LPERRLOG) && QFile::exists(LPERRLOG)){ watcher->addPath(LPERRLOG); } - if(!watched.contains(tmpLPRepFile) && QFile::exists(tmpLPRepFile)){ watcher->addPath(tmpLPRepFile); } + if(!watched.contains(LPLOG) && QFile::exists(LPLOG)){ watcher->addPath(LPLOG); WatcherUpdate(LPLOG); } + if(!watched.contains(LPERRLOG) && QFile::exists(LPERRLOG)){ watcher->addPath(LPERRLOG); WatcherUpdate(LPERRLOG); } + if(!watched.contains(tmpLPRepFile) && QFile::exists(tmpLPRepFile)){ watcher->addPath(tmpLPRepFile); WatcherUpdate(tmpLPRepFile); } //qDebug() << "watched:" << watcher->files() << watcher->directories(); }