Changeset View
Changeset View
Standalone View
Standalone View
common/changereplay.cpp
Show First 20 Lines • Show All 110 Lines • ▼ Show 20 Line(s) | 102 | [this, lastReplayedRevision, topRevision]() -> KAsync::Job<KAsync::ControlFlowFlag> { | |||
---|---|---|---|---|---|
111 | while (revision <= *topRevision) { | 111 | while (revision <= *topRevision) { | ||
112 | const auto uid = DataStore::getUidFromRevision(mMainStoreTransaction, revision); | 112 | const auto uid = DataStore::getUidFromRevision(mMainStoreTransaction, revision); | ||
113 | const auto type = DataStore::getTypeFromRevision(mMainStoreTransaction, revision); | 113 | const auto type = DataStore::getTypeFromRevision(mMainStoreTransaction, revision); | ||
114 | if (uid.isEmpty() || type.isEmpty()) { | 114 | if (uid.isEmpty() || type.isEmpty()) { | ||
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); | 118 | const auto key = Storage::Key(Storage::Identifier::fromDisplayByteArray(uid), revision); | ||
119 | const auto internalKey = key.toInternalByteArray(); | | |||
120 | const auto displayKey = key.toDisplayByteArray(); | 119 | const auto displayKey = key.toDisplayByteArray(); | ||
121 | QByteArray entityBuffer; | 120 | QByteArray entityBuffer; | ||
122 | DataStore::mainDatabase(mMainStoreTransaction, type) | 121 | DataStore::mainDatabase(mMainStoreTransaction, type) | ||
123 | .scan(internalKey, | 122 | .scan(revision, | ||
124 | [&entityBuffer](const QByteArray &key, const QByteArray &value) -> bool { | 123 | [&entityBuffer](const size_t, const QByteArray &value) -> bool { | ||
125 | entityBuffer = value; | 124 | entityBuffer = value; | ||
126 | return false; | 125 | return false; | ||
127 | }, | 126 | }, | ||
128 | [this, key](const DataStore::Error &) { SinkErrorCtx(mLogCtx) << "Failed to read the entity buffer " << key; }); | 127 | [this, key](const DataStore::Error &e) { SinkErrorCtx(mLogCtx) << "Failed to read the entity buffer " << key << "error:" << e; }); | ||
129 | 128 | | |||
130 | if (entityBuffer.isEmpty()) { | 129 | if (entityBuffer.isEmpty()) { | ||
131 | SinkErrorCtx(mLogCtx) << "Failed to replay change " << key; | 130 | SinkErrorCtx(mLogCtx) << "Failed to replay change " << key; | ||
132 | } else { | 131 | } else { | ||
133 | if (canReplay(type, displayKey, entityBuffer)) { | 132 | if (canReplay(type, displayKey, entityBuffer)) { | ||
134 | SinkTraceCtx(mLogCtx) << "Replaying " << displayKey; | 133 | SinkTraceCtx(mLogCtx) << "Replaying " << displayKey; | ||
135 | replayJob = replay(type, displayKey, entityBuffer); | 134 | replayJob = replay(type, displayKey, entityBuffer); | ||
136 | //Set the last revision we tried to replay | 135 | //Set the last revision we tried to replay | ||
▲ Show 20 Lines • Show All 68 Lines • Show Last 20 Lines |