diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-03-28 10:10:41 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-03-28 10:10:41 +0200 |
commit | 85beb06912698af92b5d9e9a489a72773164451d (patch) | |
tree | 44c054871d785c57d4de946671c74da7264a1e03 /common/synchronizer.cpp | |
parent | 547e5e29cbfc12474ab45768ff0d9342882b2633 (diff) | |
download | sink-85beb06912698af92b5d9e9a489a72773164451d.tar.gz sink-85beb06912698af92b5d9e9a489a72773164451d.zip |
Only send notifications about being connected if we did something
against the source.
We used to replay no changes and then claim the resource was online.
Diffstat (limited to 'common/synchronizer.cpp')
-rw-r--r-- | common/synchronizer.cpp | 31 |
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."}); |