diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-05-20 11:28:02 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-05-20 11:28:02 +0200 |
commit | 524e405f645edb6231f9b16fafc1f9ca36af8237 (patch) | |
tree | 471692764999bc32a3e1e5404b1466a2b3a46847 /common/synchronizer.cpp | |
parent | 256fe3fc561f1690e5c29640b9081e805ceb5532 (diff) | |
download | sink-524e405f645edb6231f9b16fafc1f9ca36af8237.tar.gz sink-524e405f645edb6231f9b16fafc1f9ca36af8237.zip |
Avoid notifcations for requests that do nothing, progress with folderid
Diffstat (limited to 'common/synchronizer.cpp')
-rw-r--r-- | common/synchronizer.cpp | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/common/synchronizer.cpp b/common/synchronizer.cpp index b9decbd..3ef7eb7 100644 --- a/common/synchronizer.cpp +++ b/common/synchronizer.cpp | |||
@@ -315,11 +315,17 @@ void Synchronizer::emitProgressNotification(Notification::NoticationType type, i | |||
315 | emit notify(n); | 315 | emit notify(n); |
316 | } | 316 | } |
317 | 317 | ||
318 | void Synchronizer::reportProgress(int progress, int total) | 318 | void Synchronizer::reportProgress(int progress, int total, const QByteArrayList &entities) |
319 | { | 319 | { |
320 | if (progress > 0 && total > 0) { | 320 | if (progress > 0 && total > 0) { |
321 | SinkLogCtx(mLogCtx) << "Progress: " << progress << " out of " << total; | 321 | SinkLogCtx(mLogCtx) << "Progress: " << progress << " out of " << total << mCurrentRequest.requestId << mCurrentRequest.applicableEntities; |
322 | emitProgressNotification(Notification::Progress, progress, total, mCurrentRequest.requestId, mCurrentRequest.applicableEntities); | 322 | const auto applicableEntities = [&] { |
323 | if (entities.isEmpty()) { | ||
324 | return mCurrentRequest.applicableEntities; | ||
325 | } | ||
326 | return entities; | ||
327 | }(); | ||
328 | emitProgressNotification(Notification::Progress, progress, total, mCurrentRequest.requestId, applicableEntities); | ||
323 | } | 329 | } |
324 | } | 330 | } |
325 | 331 | ||
@@ -371,6 +377,7 @@ KAsync::Job<void> Synchronizer::processRequest(const SyncRequest &request) | |||
371 | } else if (request.requestType == Synchronizer::SyncRequest::Synchronization) { | 377 | } else if (request.requestType == Synchronizer::SyncRequest::Synchronization) { |
372 | return KAsync::start([this, request] { | 378 | return KAsync::start([this, request] { |
373 | SinkLogCtx(mLogCtx) << "Synchronizing: " << request.query; | 379 | SinkLogCtx(mLogCtx) << "Synchronizing: " << request.query; |
380 | setBusy(true, "Synchronization has started.", request.requestId); | ||
374 | emitNotification(Notification::Info, ApplicationDomain::SyncInProgress, {}, {}, request.applicableEntities); | 381 | emitNotification(Notification::Info, ApplicationDomain::SyncInProgress, {}, {}, request.applicableEntities); |
375 | }).then(synchronizeWithSource(request.query)).then([this] { | 382 | }).then(synchronizeWithSource(request.query)).then([this] { |
376 | //Commit after every request, so implementations only have to commit more if they add a lot of data. | 383 | //Commit after every request, so implementations only have to commit more if they add a lot of data. |
@@ -408,6 +415,7 @@ KAsync::Job<void> Synchronizer::processRequest(const SyncRequest &request) | |||
408 | return KAsync::null(); | 415 | return KAsync::null(); |
409 | } else { | 416 | } else { |
410 | return KAsync::start([this, request] { | 417 | return KAsync::start([this, request] { |
418 | setBusy(true, "ChangeReplay has started.", request.requestId); | ||
411 | SinkLogCtx(mLogCtx) << "Replaying changes."; | 419 | SinkLogCtx(mLogCtx) << "Replaying changes."; |
412 | }) | 420 | }) |
413 | .then(replayNextRevision()) | 421 | .then(replayNextRevision()) |
@@ -479,11 +487,6 @@ KAsync::Job<void> Synchronizer::processSyncQueue() | |||
479 | mMessageQueue->startTransaction(); | 487 | mMessageQueue->startTransaction(); |
480 | mEntityStore->startTransaction(Sink::Storage::DataStore::ReadOnly); | 488 | mEntityStore->startTransaction(Sink::Storage::DataStore::ReadOnly); |
481 | mSyncInProgress = true; | 489 | mSyncInProgress = true; |
482 | if (request.requestType == Synchronizer::SyncRequest::Synchronization) { | ||
483 | setBusy(true, "Synchronization has started.", request.requestId); | ||
484 | } else if (request.requestType == Synchronizer::SyncRequest::ChangeReplay) { | ||
485 | setBusy(true, "ChangeReplay has started.", request.requestId); | ||
486 | } | ||
487 | mCurrentRequest = request; | 490 | mCurrentRequest = request; |
488 | }) | 491 | }) |
489 | .then(processRequest(request)) | 492 | .then(processRequest(request)) |