From e27358985e6729415a8b83a85aac0350180c95bc Mon Sep 17 00:00:00 2001 From: Minijackson Date: Wed, 27 Jun 2018 12:09:24 +0200 Subject: Fix changereplay + comment special case of readLatest --- common/changereplay.cpp | 12 +++++++----- common/storage/entitystore.cpp | 2 ++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/common/changereplay.cpp b/common/changereplay.cpp index 5817e8d..d7f46dc 100644 --- a/common/changereplay.cpp +++ b/common/changereplay.cpp @@ -115,10 +115,12 @@ KAsync::Job ChangeReplay::replayNextRevision() SinkErrorCtx(mLogCtx) << "Failed to read uid or type for revison: " << revision << uid << type; } else { // TODO: should not use internal representations - const auto key = Storage::Key(Storage::Identifier::fromDisplayByteArray(uid), revision).toInternalByteArray(); + const auto key = Storage::Key(Storage::Identifier::fromDisplayByteArray(uid), revision); + const auto internalKey = key.toInternalByteArray(); + const auto displayKey = key.toDisplayByteArray(); QByteArray entityBuffer; DataStore::mainDatabase(mMainStoreTransaction, type) - .scan(key, + .scan(internalKey, [&entityBuffer](const QByteArray &key, const QByteArray &value) -> bool { entityBuffer = value; return false; @@ -128,9 +130,9 @@ KAsync::Job ChangeReplay::replayNextRevision() if (entityBuffer.isEmpty()) { SinkErrorCtx(mLogCtx) << "Failed to replay change " << key; } else { - if (canReplay(type, key, entityBuffer)) { - SinkTraceCtx(mLogCtx) << "Replaying " << key; - replayJob = replay(type, key, entityBuffer); + if (canReplay(type, displayKey, entityBuffer)) { + SinkTraceCtx(mLogCtx) << "Replaying " << displayKey; + replayJob = replay(type, displayKey, entityBuffer); //Set the last revision we tried to replay *lastReplayedRevision = revision; //Execute replay job and commit diff --git a/common/storage/entitystore.cpp b/common/storage/entitystore.cpp index d3420e4..3addf94 100644 --- a/common/storage/entitystore.cpp +++ b/common/storage/entitystore.cpp @@ -490,6 +490,8 @@ void EntityStore::readLatest(const QByteArray &type, const QByteArray &key, cons { Q_ASSERT(d); Q_ASSERT(!key.isEmpty()); + // TODO: we shouldn't pass whole keys to this function + // check the testSingle test from querytest const auto internalKey = [&key]() { if(key.size() == Identifier::DISPLAY_REPR_SIZE) { return Identifier::fromDisplayByteArray(key).toInternalByteArray(); -- cgit v1.2.3