summaryrefslogtreecommitdiffstats
path: root/common/synchronizer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'common/synchronizer.cpp')
-rw-r--r--common/synchronizer.cpp31
1 files changed, 29 insertions, 2 deletions
diff --git a/common/synchronizer.cpp b/common/synchronizer.cpp
index 329841b..d3de20b 100644
--- a/common/synchronizer.cpp
+++ b/common/synchronizer.cpp
@@ -337,8 +337,12 @@ KAsync::Job<void> Synchronizer::processRequest(const SyncRequest &request)
337 if (error) { 337 if (error) {
338 //Emit notification with error 338 //Emit notification with error
339 SinkWarningCtx(mLogCtx) << "Synchronization failed: " << error.errorMessage; 339 SinkWarningCtx(mLogCtx) << "Synchronization failed: " << error.errorMessage;
340 if (error.errorCode == ApplicationDomain::ConnectionError) {
341 emitNotification(Notification::Status, ApplicationDomain::OfflineStatus, "Synchronization has ended.", request.requestId);
342 } else {
343 emitNotification(Notification::Status, ApplicationDomain::ErrorStatus, "Synchronization has ended.", request.requestId);
344 }
340 emitNotification(Notification::Warning, ApplicationDomain::SyncError, {}, {}, request.applicableEntities); 345 emitNotification(Notification::Warning, ApplicationDomain::SyncError, {}, {}, request.applicableEntities);
341 emitNotification(Notification::Status, ApplicationDomain::ErrorStatus, "Synchronization has ended.", request.requestId);
342 return KAsync::error(error); 346 return KAsync::error(error);
343 } else { 347 } else {
344 SinkLogCtx(mLogCtx) << "Done Synchronizing"; 348 SinkLogCtx(mLogCtx) << "Done Synchronizing";
@@ -363,7 +367,30 @@ KAsync::Job<void> Synchronizer::processRequest(const SyncRequest &request)
363 } 367 }
364 }); 368 });
365 } else if (request.requestType == Synchronizer::SyncRequest::ChangeReplay) { 369 } else if (request.requestType == Synchronizer::SyncRequest::ChangeReplay) {
366 return replayNextRevision(); 370 if (ChangeReplay::allChangesReplayed()) {
371 return KAsync::null();
372 } else {
373 return KAsync::start([this, request] {
374 SinkLogCtx(mLogCtx) << "Replaying changes.";
375 emitNotification(Notification::Status, ApplicationDomain::BusyStatus, "Changereplay has started.", "changereplay");
376 })
377 .then(replayNextRevision())
378 .then<void>([this, request](const KAsync::Error &error) {
379 if (error) {
380 SinkWarningCtx(mLogCtx) << "Changereplay failed: " << error.errorMessage;
381 if (error.errorCode == ApplicationDomain::ConnectionError) {
382 emitNotification(Notification::Status, ApplicationDomain::OfflineStatus, "Changereplay has ended.", "changereplay");
383 } else {
384 emitNotification(Notification::Status, ApplicationDomain::ErrorStatus, "Changereplay has ended.", "changereplay");
385 }
386 return KAsync::error(error);
387 } else {
388 SinkLogCtx(mLogCtx) << "Done replaying changes";
389 emitNotification(Notification::Status, ApplicationDomain::ConnectedStatus, "All changes have been replayed.", "changereplay");
390 return KAsync::null();
391 }
392 });
393 }
367 } else { 394 } else {
368 SinkWarningCtx(mLogCtx) << "Unknown request type: " << request.requestType; 395 SinkWarningCtx(mLogCtx) << "Unknown request type: " << request.requestType;
369 return KAsync::error(KAsync::Error{"Unknown request type."}); 396 return KAsync::error(KAsync::Error{"Unknown request type."});