summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--common/changereplay.cpp12
-rw-r--r--common/storage/entitystore.cpp2
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<void> ChangeReplay::replayNextRevision()
115 SinkErrorCtx(mLogCtx) << "Failed to read uid or type for revison: " << revision << uid << type; 115 SinkErrorCtx(mLogCtx) << "Failed to read uid or type for revison: " << revision << uid << type;
116 } else { 116 } else {
117 // TODO: should not use internal representations 117 // TODO: should not use internal representations
118 const auto key = Storage::Key(Storage::Identifier::fromDisplayByteArray(uid), revision).toInternalByteArray(); 118 const auto key = Storage::Key(Storage::Identifier::fromDisplayByteArray(uid), revision);
119 const auto internalKey = key.toInternalByteArray();
120 const auto displayKey = key.toDisplayByteArray();
119 QByteArray entityBuffer; 121 QByteArray entityBuffer;
120 DataStore::mainDatabase(mMainStoreTransaction, type) 122 DataStore::mainDatabase(mMainStoreTransaction, type)
121 .scan(key, 123 .scan(internalKey,
122 [&entityBuffer](const QByteArray &key, const QByteArray &value) -> bool { 124 [&entityBuffer](const QByteArray &key, const QByteArray &value) -> bool {
123 entityBuffer = value; 125 entityBuffer = value;
124 return false; 126 return false;
@@ -128,9 +130,9 @@ KAsync::Job<void> ChangeReplay::replayNextRevision()
128 if (entityBuffer.isEmpty()) { 130 if (entityBuffer.isEmpty()) {
129 SinkErrorCtx(mLogCtx) << "Failed to replay change " << key; 131 SinkErrorCtx(mLogCtx) << "Failed to replay change " << key;
130 } else { 132 } else {
131 if (canReplay(type, key, entityBuffer)) { 133 if (canReplay(type, displayKey, entityBuffer)) {
132 SinkTraceCtx(mLogCtx) << "Replaying " << key; 134 SinkTraceCtx(mLogCtx) << "Replaying " << displayKey;
133 replayJob = replay(type, key, entityBuffer); 135 replayJob = replay(type, displayKey, entityBuffer);
134 //Set the last revision we tried to replay 136 //Set the last revision we tried to replay
135 *lastReplayedRevision = revision; 137 *lastReplayedRevision = revision;
136 //Execute replay job and commit 138 //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
490{ 490{
491 Q_ASSERT(d); 491 Q_ASSERT(d);
492 Q_ASSERT(!key.isEmpty()); 492 Q_ASSERT(!key.isEmpty());
493 // TODO: we shouldn't pass whole keys to this function
494 // check the testSingle test from querytest
493 const auto internalKey = [&key]() { 495 const auto internalKey = [&key]() {
494 if(key.size() == Identifier::DISPLAY_REPR_SIZE) { 496 if(key.size() == Identifier::DISPLAY_REPR_SIZE) {
495 return Identifier::fromDisplayByteArray(key).toInternalByteArray(); 497 return Identifier::fromDisplayByteArray(key).toInternalByteArray();