diff options
-rw-r--r-- | common/pipeline.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/common/pipeline.cpp b/common/pipeline.cpp index 01db980..d850154 100644 --- a/common/pipeline.cpp +++ b/common/pipeline.cpp | |||
@@ -339,6 +339,34 @@ KAsync::Job<qint64> Pipeline::deletedEntity(void const *command, size_t size) | |||
339 | const QByteArray bufferType = QByteArray(reinterpret_cast<char const*>(deleteEntity->domainType()->Data()), deleteEntity->domainType()->size()); | 339 | const QByteArray bufferType = QByteArray(reinterpret_cast<char const*>(deleteEntity->domainType()->Data()), deleteEntity->domainType()->size()); |
340 | const QByteArray key = QByteArray(reinterpret_cast<char const*>(deleteEntity->entityId()->Data()), deleteEntity->entityId()->size()); | 340 | const QByteArray key = QByteArray(reinterpret_cast<char const*>(deleteEntity->entityId()->Data()), deleteEntity->entityId()->size()); |
341 | 341 | ||
342 | bool found = false; | ||
343 | bool alreadyRemoved = false; | ||
344 | d->transaction.openDatabase(bufferType + ".main").findLatest(key, [&found, &alreadyRemoved](const QByteArray &key, const QByteArray &data) -> bool { | ||
345 | Akonadi2::EntityBuffer buffer(const_cast<const char *>(data.data()), data.size()); | ||
346 | auto entity = Akonadi2::GetEntity(data.data()); | ||
347 | if (entity && entity->metadata()) { | ||
348 | auto metadata = Akonadi2::GetMetadata(entity->metadata()->Data()); | ||
349 | found = true; | ||
350 | if (metadata->operation() == Akonadi2::Operation_Removal) { | ||
351 | alreadyRemoved = true; | ||
352 | } | ||
353 | |||
354 | } | ||
355 | return false; | ||
356 | }, | ||
357 | [](const Storage::Error &error) { | ||
358 | Warning() << "Failed to read old revision from storage: " << error.message; | ||
359 | }); | ||
360 | |||
361 | if (!found) { | ||
362 | Warning() << "Failed to find entity " << key; | ||
363 | return KAsync::error<qint64>(0); | ||
364 | } | ||
365 | if (alreadyRemoved) { | ||
366 | Warning() << "Entity is already removed " << key; | ||
367 | return KAsync::error<qint64>(0); | ||
368 | } | ||
369 | |||
342 | const qint64 newRevision = Akonadi2::Storage::maxRevision(d->transaction) + 1; | 370 | const qint64 newRevision = Akonadi2::Storage::maxRevision(d->transaction) + 1; |
343 | 371 | ||
344 | //Add metadata buffer | 372 | //Add metadata buffer |