From 4cb1c1e6103459e54d931b8672674f5f49f8ac2f Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Fri, 18 May 2018 11:20:40 +0200 Subject: Skip change-replay for already removed entites. This is required to be able to resolve change-replay failures by removing the entity. --- common/synchronizer.cpp | 13 +++++++++++++ examples/imapresource/imapresource.cpp | 5 ++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/common/synchronizer.cpp b/common/synchronizer.cpp index 51e53c8..037a01f 100644 --- a/common/synchronizer.cpp +++ b/common/synchronizer.cpp @@ -626,6 +626,19 @@ KAsync::Job Synchronizer::replay(const QByteArray &type, const QByteArray } SinkLogCtx(mLogCtx) << "Replaying: " << key << "Type: " << type << "Uid: " << uid << "Rid: " << oldRemoteId << "Revision: " << metadataBuffer->revision(); + //If the entity has been removed already and this is not the removal, skip over. + //This is important so we can unblock changereplay by removing entities. + bool skipOver = false; + store().readLatest(type, uid, [&](const ApplicationDomain::ApplicationDomainType &, Sink::Operation latestOperation) { + if (latestOperation == Sink::Operation_Removal && operation != Sink::Operation_Removal) { + skipOver = true; + } + }); + if (skipOver) { + SinkLogCtx(mLogCtx) << "Skipping over already removed entity"; + return KAsync::null(); + } + KAsync::Job job = KAsync::null(); //TODO This requires supporting every domain type here as well. Can we solve this better so we can do the dispatch somewhere centrally? if (type == ApplicationDomain::getTypeName()) { diff --git a/examples/imapresource/imapresource.cpp b/examples/imapresource/imapresource.cpp index 0527902..4151afa 100644 --- a/examples/imapresource/imapresource.cpp +++ b/examples/imapresource/imapresource.cpp @@ -691,10 +691,9 @@ public: { if (operation != Sink::Operation_Creation) { if(oldRemoteId.isEmpty()) { - // return KAsync::error("Tried to replay modification without old remoteId."); - qWarning() << "Tried to replay modification without old remoteId."; + SinkWarning() << "Tried to replay modification without old remoteId."; // Since we can't recover from the situation we just skip over the revision. - // FIXME figure out how we can ever end up in this situation + // This can for instance happen if creation failed, and we then process a removal or modification. return KAsync::null(); } } -- cgit v1.2.3