From 817039ddf39e3535c043234c8ce29e3e5123f52c Mon Sep 17 00:00:00 2001 From: Klaas Freitag Date: Tue, 19 Feb 2013 17:24:10 +0100 Subject: Simplify and fix startup: Steer starting of sync from folderman. --- src/mirall/application.cpp | 4 ++++ src/mirall/folderman.cpp | 7 +++++++ src/mirall/folderman.h | 2 ++ src/mirall/folderwatcher.cpp | 6 ++---- src/mirall/folderwatcher.h | 3 --- 5 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/mirall/application.cpp b/src/mirall/application.cpp index 9cf26fc3e..7c238a42c 100644 --- a/src/mirall/application.cpp +++ b/src/mirall/application.cpp @@ -373,6 +373,10 @@ void Application::slotAuthCheck( const QString& ,QNetworkReply *reply ) if( _tray ) _tray->showMessage(tr("%1 Sync Started").arg(_theme->appName()), tr("Sync started for %1 configured sync folder(s).").arg(cnt)); + + // queue up the sync for all folders. + _folderMan->slotScheduleAllFolders(); + computeOverallSyncStatus(); _actionAddFolder->setEnabled( true ); diff --git a/src/mirall/folderman.cpp b/src/mirall/folderman.cpp index 3687d2999..6923027fe 100644 --- a/src/mirall/folderman.cpp +++ b/src/mirall/folderman.cpp @@ -352,6 +352,13 @@ SyncResult FolderMan::syncResult( const QString& alias ) return res; } +void FolderMan::slotScheduleAllFolders() +{ + foreach( Folder *f, _folderMap.values() ) { + slotScheduleSync( f->alias() ); + } +} + /* * if a folder wants to be synced, it calls this slot and is added * to the queue. The slot to actually start a sync is called afterwards. diff --git a/src/mirall/folderman.h b/src/mirall/folderman.h index 0826d844c..d0110e277 100644 --- a/src/mirall/folderman.h +++ b/src/mirall/folderman.h @@ -98,6 +98,8 @@ public slots: // the current one will finish. void setSyncEnabled( bool ); + void slotScheduleAllFolders(); + private slots: // slot to add a folder to the syncing queue void slotScheduleSync( const QString & ); diff --git a/src/mirall/folderwatcher.cpp b/src/mirall/folderwatcher.cpp index 73c170918..55634be33 100644 --- a/src/mirall/folderwatcher.cpp +++ b/src/mirall/folderwatcher.cpp @@ -47,8 +47,7 @@ FolderWatcher::FolderWatcher(const QString &root, QObject *parent) _eventsEnabled(true), _eventInterval(DEFAULT_EVENT_INTERVAL_MSEC), _root(root), - _processTimer(new QTimer(this)), - _initialSyncDone(false) + _processTimer(new QTimer(this)) { _d = new FolderWatcherPrivate(this); @@ -147,13 +146,12 @@ void FolderWatcher::slotProcessTimerTimeout() { qDebug() << "* Processing of event queue for" << root(); - if (!_pendingPathes.empty() || !_initialSyncDone) { + if (!_pendingPathes.empty() ) { QStringList notifyPaths = _pendingPathes.keys(); _pendingPathes.clear(); //qDebug() << lastEventTime << eventTime; qDebug() << " * Notify" << notifyPaths.size() << "change items for" << root(); emit folderChanged(notifyPaths); - _initialSyncDone = true; } } diff --git a/src/mirall/folderwatcher.h b/src/mirall/folderwatcher.h index 40fa0c00f..f920ffab4 100644 --- a/src/mirall/folderwatcher.h +++ b/src/mirall/folderwatcher.h @@ -134,9 +134,6 @@ private: // QStringList _pendingPaths; QTimer *_processTimer; QStringList _ignores; - // for the initial synchronization, without - // any file changed - bool _initialSyncDone; friend class FolderWatcherPrivate; }; -- cgit v1.2.3