summaryrefslogtreecommitdiffstats
path: root/common/synchronizer.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2016-11-22 14:27:37 +0100
committerChristian Mollekopf <chrigi_1@fastmail.fm>2016-11-22 14:27:37 +0100
commitc799105ca6b4107fa19de9845247f1f3322ea6ef (patch)
tree9a9da831861b5094936f8b62431fb5e20ce759f5 /common/synchronizer.cpp
parentc6af4d6ed59235d8fec52aeddfcd9a65607139ff (diff)
downloadsink-c799105ca6b4107fa19de9845247f1f3322ea6ef.tar.gz
sink-c799105ca6b4107fa19de9845247f1f3322ea6ef.zip
Ensure we always process the full queue and that flushing works.
Diffstat (limited to 'common/synchronizer.cpp')
-rw-r--r--common/synchronizer.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/common/synchronizer.cpp b/common/synchronizer.cpp
index 8010689..5bde597 100644
--- a/common/synchronizer.cpp
+++ b/common/synchronizer.cpp
@@ -287,11 +287,15 @@ KAsync::Job<void> Synchronizer::processSyncQueue()
287 mSyncStore.clear(); 287 mSyncStore.clear();
288 mMessageQueue->commit(); 288 mMessageQueue->commit();
289 mSyncInProgress = false; 289 mSyncInProgress = false;
290 if (allChangesReplayed()) {
291 emit changesReplayed();
292 }
290 if (error) { 293 if (error) {
291 SinkWarning() << "Error during sync: " << error.errorMessage; 294 SinkWarning() << "Error during sync: " << error.errorMessage;
292 return KAsync::error(error); 295 return KAsync::error(error);
293 } 296 }
294 return KAsync::null<void>(); 297 //In case we got more requests meanwhile.
298 return processSyncQueue();
295 }); 299 });
296} 300}
297 301
@@ -414,6 +418,15 @@ KAsync::Job<QByteArray> Synchronizer::replay(const ApplicationDomain::Folder &,
414 return KAsync::null<QByteArray>(); 418 return KAsync::null<QByteArray>();
415} 419}
416 420
421bool Synchronizer::allChangesReplayed()
422{
423 if (!mSyncRequestQueue.isEmpty()) {
424 SinkTrace() << "Queue is not empty";
425 return false;
426 }
427 return ChangeReplay::allChangesReplayed();
428}
429
417#define REGISTER_TYPE(T) \ 430#define REGISTER_TYPE(T) \
418 template void Synchronizer::createOrModify(const QByteArray &bufferType, const QByteArray &remoteId, const T &entity, const QHash<QByteArray, Sink::Query::Comparator> &mergeCriteria); \ 431 template void Synchronizer::createOrModify(const QByteArray &bufferType, const QByteArray &remoteId, const T &entity, const QHash<QByteArray, Sink::Query::Comparator> &mergeCriteria); \
419 template void Synchronizer::modify(const T &entity); 432 template void Synchronizer::modify(const T &entity);