From 8af257a4cd1bdb63354f6caf47d5d1e36e2c8ad5 Mon Sep 17 00:00:00 2001 From: Klaas Freitag Date: Thu, 6 Dec 2012 18:38:45 +0100 Subject: [PATCH] Start fs watching with a delay of 2 seconds to don't catch the journal changes. --- src/mirall/csyncthread.cpp | 5 ----- src/mirall/folder.cpp | 2 +- src/mirall/folderwatcher.cpp | 6 ++++++ src/mirall/folderwatcher.h | 22 +++++++++++++++------- 4 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/mirall/csyncthread.cpp b/src/mirall/csyncthread.cpp index 51e8d67ae..0e79a26a6 100644 --- a/src/mirall/csyncthread.cpp +++ b/src/mirall/csyncthread.cpp @@ -217,11 +217,6 @@ cleanup: qDebug() << "CSync run took " << t.elapsed() << " Milliseconds"; qDebug() << "CSync Waiting a bit to let OS finish up IO"; -#ifdef Q_OS_WIN - Sleep(2000); -#else - ::sleep(2); -#endif qDebug() << "CSync End Waiting"; emit(finished()); diff --git a/src/mirall/folder.cpp b/src/mirall/folder.cpp index 9dce51b95..5dcc686e0 100644 --- a/src/mirall/folder.cpp +++ b/src/mirall/folder.cpp @@ -280,7 +280,7 @@ void Folder::slotSyncStarted() void Folder::slotSyncFinished(const SyncResult &result) { - _watcher->setEventsEnabled(true); + _watcher->setEventsEnabledDelayed(2000); qDebug() << "OO folder slotSyncFinished: result: " << int(result.status()) << " local: " << result.localRunOnly(); emit syncStateChange(); diff --git a/src/mirall/folderwatcher.cpp b/src/mirall/folderwatcher.cpp index ef60ab9cb..73c170918 100644 --- a/src/mirall/folderwatcher.cpp +++ b/src/mirall/folderwatcher.cpp @@ -102,6 +102,12 @@ bool FolderWatcher::eventsEnabled() const return _eventsEnabled; } +void FolderWatcher::setEventsEnabledDelayed( int delay_msec ) +{ + qDebug() << "Starting Event logging again in " << delay_msec << " milliseconds"; + QTimer::singleShot( delay_msec, this, SLOT(setEventsEnabled())); +} + void FolderWatcher::setEventsEnabled(bool enabled) { qDebug() << " * event notification " << (enabled ? "enabled" : "disabled"); diff --git a/src/mirall/folderwatcher.h b/src/mirall/folderwatcher.h index 494040f36..40fa0c00f 100644 --- a/src/mirall/folderwatcher.h +++ b/src/mirall/folderwatcher.h @@ -75,13 +75,6 @@ public: */ bool eventsEnabled() const; - /** - * Enabled or disables folderChanged() events. - * If disabled, events are accumulated and emptied - * the next time a folderChanged() event happens. - */ - void setEventsEnabled(bool enabled); - /** * Clear all pending events */ @@ -100,6 +93,21 @@ public: void setEventInterval(int seconds); QStringList ignores() const; +public slots: + /** + * Enabled or disables folderChanged() events. + * If disabled, events are accumulated and emptied + * the next time a folderChanged() event happens. + */ + void setEventsEnabled(bool enabled=true); + + /** + * @brief setEventsEnabledDelayed - start event logging after a while + * @param delay - delay time in milliseconds + * @param enabled - enable the events. + */ + void setEventsEnabledDelayed( int ); + signals: /** * Emitted when one of the paths is changed