Finish danimo's patch that refactor the scheduler

Wait a full poll interval after the end of the sync
This commit is contained in:
Olivier Goffart 2013-08-05 14:35:01 +02:00
parent 578bcc3522
commit 6fb5c04bde
3 changed files with 8 additions and 11 deletions

View file

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

View file

@ -172,11 +172,6 @@ private slots:
void slotPollTimerTimeout(); 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 * Triggered by a file system watcher on the local sync dir
*/ */

View file

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