diff options
-rw-r--r-- | common/pipeline.cpp | 24 | ||||
-rw-r--r-- | tests/pipelinetest.cpp | 3 |
2 files changed, 20 insertions, 7 deletions
diff --git a/common/pipeline.cpp b/common/pipeline.cpp index 38029a3..b05cb2f 100644 --- a/common/pipeline.cpp +++ b/common/pipeline.cpp | |||
@@ -172,6 +172,7 @@ KAsync::Job<qint64> Pipeline::newEntity(void const *command, size_t size) | |||
172 | auto metadataBuilder = Akonadi2::MetadataBuilder(metadataFbb); | 172 | auto metadataBuilder = Akonadi2::MetadataBuilder(metadataFbb); |
173 | metadataBuilder.add_revision(newRevision); | 173 | metadataBuilder.add_revision(newRevision); |
174 | metadataBuilder.add_processed(false); | 174 | metadataBuilder.add_processed(false); |
175 | metadataBuilder.add_operation(Akonadi2::Operation_Creation); | ||
175 | auto metadataBuffer = metadataBuilder.Finish(); | 176 | auto metadataBuffer = metadataBuilder.Finish(); |
176 | Akonadi2::FinishMetadataBuffer(metadataFbb, metadataBuffer); | 177 | Akonadi2::FinishMetadataBuffer(metadataFbb, metadataBuffer); |
177 | 178 | ||
@@ -277,6 +278,7 @@ KAsync::Job<qint64> Pipeline::modifiedEntity(void const *command, size_t size) | |||
277 | auto metadataBuilder = Akonadi2::MetadataBuilder(metadataFbb); | 278 | auto metadataBuilder = Akonadi2::MetadataBuilder(metadataFbb); |
278 | metadataBuilder.add_revision(newRevision); | 279 | metadataBuilder.add_revision(newRevision); |
279 | metadataBuilder.add_processed(false); | 280 | metadataBuilder.add_processed(false); |
281 | metadataBuilder.add_operation(Akonadi2::Operation_Modification); | ||
280 | auto metadataBuffer = metadataBuilder.Finish(); | 282 | auto metadataBuffer = metadataBuilder.Finish(); |
281 | Akonadi2::FinishMetadataBuffer(metadataFbb, metadataBuffer); | 283 | Akonadi2::FinishMetadataBuffer(metadataFbb, metadataBuffer); |
282 | 284 | ||
@@ -300,8 +302,6 @@ KAsync::Job<qint64> Pipeline::deletedEntity(void const *command, size_t size) | |||
300 | { | 302 | { |
301 | Trace() << "Pipeline: Deleted Entity"; | 303 | Trace() << "Pipeline: Deleted Entity"; |
302 | 304 | ||
303 | const qint64 newRevision = Akonadi2::Storage::maxRevision(d->transaction) + 1; | ||
304 | |||
305 | { | 305 | { |
306 | flatbuffers::Verifier verifyer(reinterpret_cast<const uint8_t *>(command), size); | 306 | flatbuffers::Verifier verifyer(reinterpret_cast<const uint8_t *>(command), size); |
307 | if (!Akonadi2::Commands::VerifyDeleteEntityBuffer(verifyer)) { | 307 | if (!Akonadi2::Commands::VerifyDeleteEntityBuffer(verifyer)) { |
@@ -315,11 +315,21 @@ KAsync::Job<qint64> Pipeline::deletedEntity(void const *command, size_t size) | |||
315 | const QByteArray key = QByteArray(reinterpret_cast<char const*>(deleteEntity->entityId()->Data()), deleteEntity->entityId()->size()); | 315 | const QByteArray key = QByteArray(reinterpret_cast<char const*>(deleteEntity->entityId()->Data()), deleteEntity->entityId()->size()); |
316 | const qint64 baseRevision = deleteEntity->revision(); | 316 | const qint64 baseRevision = deleteEntity->revision(); |
317 | 317 | ||
318 | //TODO instead of deleting the entry, a new revision should be created that marks the entity as deleted | 318 | const qint64 newRevision = Akonadi2::Storage::maxRevision(d->transaction) + 1; |
319 | //TODO remove all revisions? | 319 | |
320 | d->transaction.openDatabase(bufferType + ".main").remove(Akonadi2::Storage::assembleKey(key, baseRevision)); | 320 | //Add metadata buffer |
321 | Akonadi2::Storage::setMaxRevision(d->transaction, newRevision); | 321 | flatbuffers::FlatBufferBuilder metadataFbb; |
322 | Akonadi2::Storage::recordRevision(d->transaction, newRevision, key, bufferType); | 322 | auto metadataBuilder = Akonadi2::MetadataBuilder(metadataFbb); |
323 | metadataBuilder.add_revision(newRevision); | ||
324 | metadataBuilder.add_processed(false); | ||
325 | metadataBuilder.add_operation(Akonadi2::Operation_Removal); | ||
326 | auto metadataBuffer = metadataBuilder.Finish(); | ||
327 | Akonadi2::FinishMetadataBuffer(metadataFbb, metadataBuffer); | ||
328 | |||
329 | flatbuffers::FlatBufferBuilder fbb; | ||
330 | EntityBuffer::assembleEntityBuffer(fbb, metadataFbb.GetBufferPointer(), metadataFbb.GetSize(), 0, 0, 0, 0); | ||
331 | |||
332 | storeNewRevision(newRevision, fbb, bufferType, key); | ||
323 | Log() << "Pipeline: deleted entity: "<< newRevision; | 333 | Log() << "Pipeline: deleted entity: "<< newRevision; |
324 | 334 | ||
325 | return KAsync::start<qint64>([this, key, bufferType, newRevision](KAsync::Future<qint64> &future) { | 335 | return KAsync::start<qint64>([this, key, bufferType, newRevision](KAsync::Future<qint64> &future) { |
diff --git a/tests/pipelinetest.cpp b/tests/pipelinetest.cpp index 5dede64..4cff511 100644 --- a/tests/pipelinetest.cpp +++ b/tests/pipelinetest.cpp | |||
@@ -246,6 +246,9 @@ private Q_SLOTS: | |||
246 | pipeline.deletedEntity(deleteCommand.constData(), deleteCommand.size()); | 246 | pipeline.deletedEntity(deleteCommand.constData(), deleteCommand.size()); |
247 | pipeline.commit(); | 247 | pipeline.commit(); |
248 | 248 | ||
249 | //We have a new revision that indicates the deletion | ||
250 | QCOMPARE(getKeys("org.kde.pipelinetest.instance1", "event.main").size(), 2); | ||
251 | |||
249 | //Cleanup old revisions | 252 | //Cleanup old revisions |
250 | pipeline.startTransaction(); | 253 | pipeline.startTransaction(); |
251 | pipeline.cleanupRevision(2); | 254 | pipeline.cleanupRevision(2); |