Просмотр исходного кода

Finish danimo's patch that refactor the scheduler

Wait a full poll interval after the end of the sync
Olivier Goffart 12 лет назад
Родитель
Сommit
6fb5c04bde
3 измененных файлов с 8 добавлено и 11 удалено
  1. 4 6
      src/mirall/folder.cpp
  2. 0 5
      src/mirall/folder.h
  3. 4 0
      src/mirall/folderman.cpp

+ 4 - 6
src/mirall/folder.cpp

@@ -83,6 +83,7 @@ Folder::Folder(const QString &alias, const QString &path, const QString& secondP
 
     ServerActionNotifier *notifier = new ServerActionNotifier(this);
     connect(notifier, SIGNAL(guiLog(QString,QString)), Logger::instance(), SIGNAL(optionalGuiLog(QString,QString)));
+    connect(this, SIGNAL(syncFinished(SyncResult)), this, SLOT(slotSyncFinished(SyncResult)));
     connect(this, SIGNAL(syncFinished(SyncResult)), notifier, SLOT(slotSyncFinished(SyncResult)));
 
     // check if the local path exists
@@ -251,12 +252,6 @@ void Folder::slotChanged(const QStringList &pathList)
     evaluateSync(pathList);
 }
 
-void Folder::slotSyncStarted()
-{
-    // disable events until syncing is done
-    _watcher->setEventsEnabled(false);
-}
-
 void Folder::slotSyncFinished(const SyncResult &result)
 {
     _watcher->setEventsEnabledDelayed(2000);
@@ -543,6 +538,9 @@ void Folder::startSync(const QStringList &pathList)
 
     _thread->start();
     QMetaObject::invokeMethod(_csync, "startSync", Qt::QueuedConnection);
+
+    // disable events until syncing is done
+    _watcher->setEventsEnabled(false);
     emit syncStarted();
 }
 

+ 0 - 5
src/mirall/folder.h

@@ -172,11 +172,6 @@ private slots:
 
     void slotPollTimerTimeout();
 
-
-    /** called when the watcher detect a list of changed paths */
-
-    void slotSyncStarted();
-
     /**
      * Triggered by a file system watcher on the local sync dir
      */

+ 4 - 0
src/mirall/folderman.cpp

@@ -56,6 +56,7 @@ FolderMan::FolderMan(QObject *parent) :
     qDebug() << "setting remote poll timer interval to" << polltime << "msec";
     _pollTimer->setInterval( polltime );
     QObject::connect(_pollTimer, SIGNAL(timeout()), this, SLOT(slotScheduleAllFolders()));
+    _pollTimer->setSingleShot(true);
     _pollTimer->start();
 }
 
@@ -358,6 +359,7 @@ void FolderMan::slotScheduleSync( const QString& alias )
     } else {
         qDebug() << " II> Sync for folder " << alias << " already scheduled, do not enqueue!";
     }
+    slotScheduleFolderSync();
 }
 
 void FolderMan::setSyncEnabled( bool enabled )
@@ -391,6 +393,7 @@ void FolderMan::slotScheduleFolderSync()
             _currentSyncFolder = alias;
             if (f->syncEnabled()) {
                 f->startSync( QStringList() );
+                _pollTimer->stop();
             }
         }
     }
@@ -411,6 +414,7 @@ void FolderMan::slotFolderSyncFinished( const SyncResult& )
 
     _currentSyncFolder.clear();
     QTimer::singleShot(200, this, SLOT(slotScheduleFolderSync()));
+    _pollTimer->start();
 }
 
 void FolderMan::addFolderDefinition(const QString& alias, const QString& sourceFolder, const QString& targetPath )