From 227610b7399905fca38e0f09053d78e2e866f32e Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Sat, 20 May 2017 16:55:21 +0200 Subject: Ensure change-replay errors make it through to the correct error handling and are appropriately dealt with. --- common/changereplay.cpp | 7 ++++++- common/synchronizer.cpp | 7 +++++-- examples/imapresource/imapresource.cpp | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/common/changereplay.cpp b/common/changereplay.cpp index 75b9a4c..0adbd78 100644 --- a/common/changereplay.cpp +++ b/common/changereplay.cpp @@ -147,7 +147,7 @@ KAsync::Job ChangeReplay::replayNextRevision() if (error) { SinkWarningCtx(mLogCtx) << "Change replay failed: " << error << "Last replayed revision: " << *lastReplayedRevision; //We're probably not online or so, so postpone retrying - return KAsync::value(KAsync::Break); + return KAsync::value(KAsync::Break).then(KAsync::error(error)); } SinkTraceCtx(mLogCtx) << "Replayed until: " << *lastReplayedRevision; @@ -179,6 +179,11 @@ KAsync::Job ChangeReplay::replayNextRevision() emit changesReplayed(); } } + if (error) { + return KAsync::error(error); + } else { + return KAsync::null(); + } }).guard(&mGuard); } diff --git a/common/synchronizer.cpp b/common/synchronizer.cpp index 3ef7eb7..b1ff29c 100644 --- a/common/synchronizer.cpp +++ b/common/synchronizer.cpp @@ -629,11 +629,14 @@ KAsync::Job Synchronizer::replay(const QByteArray &type, const QByteArray } }) .then([this](const KAsync::Error &error) { + //We need to commit here otherwise the next change-replay step will abort the transaction + mSyncStore.clear(); + mSyncTransaction.commit(); if (error) { SinkWarningCtx(mLogCtx) << "Failed to replay change: " << error.errorMessage; + return KAsync::error(error); } - mSyncStore.clear(); - mSyncTransaction.commit(); + return KAsync::null(); }); } diff --git a/examples/imapresource/imapresource.cpp b/examples/imapresource/imapresource.cpp index bfe43bf..29ff03b 100644 --- a/examples/imapresource/imapresource.cpp +++ b/examples/imapresource/imapresource.cpp @@ -680,7 +680,7 @@ public: if (error) { SinkWarning() << "Error during changereplay: " << error.errorMessage; return imap->logout() - .then(KAsync::error(error)); + .then(KAsync::error(getError(error))); } return imap->logout() .then(KAsync::value(remoteId)); -- cgit v1.2.3