diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-09-13 12:42:31 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-09-13 12:42:31 +0200 |
commit | c12a9a09da59b9e418316dba02e6215cb55e47ee (patch) | |
tree | 05498d9a42e399bcca787f40c1fc473fb09e680e /common/storage | |
parent | 55fe06979ceebe67553135b43aa47e70d931304b (diff) | |
parent | ebdb89b8bb482bbb5ecd544c3d38bef35fc7d820 (diff) | |
download | sink-0.4.0.tar.gz sink-0.4.0.zip |
Merge commit 'ebdb89b8bb482bbb5ecd544c3d38bef35fc7d820'v0.4.0
Diffstat (limited to 'common/storage')
-rw-r--r-- | common/storage/entitystore.cpp | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/common/storage/entitystore.cpp b/common/storage/entitystore.cpp index 22e5ae3..5514e31 100644 --- a/common/storage/entitystore.cpp +++ b/common/storage/entitystore.cpp | |||
@@ -267,7 +267,7 @@ bool EntityStore::add(const QByteArray &type, ApplicationDomain::ApplicationDoma | |||
267 | [&](const DataStore::Error &error) { SinkWarningCtx(d->logCtx) << "Failed to write entity" << entity.identifier() << newRevision; }); | 267 | [&](const DataStore::Error &error) { SinkWarningCtx(d->logCtx) << "Failed to write entity" << entity.identifier() << newRevision; }); |
268 | DataStore::setMaxRevision(d->transaction, newRevision); | 268 | DataStore::setMaxRevision(d->transaction, newRevision); |
269 | DataStore::recordRevision(d->transaction, newRevision, entity.identifier(), type); | 269 | DataStore::recordRevision(d->transaction, newRevision, entity.identifier(), type); |
270 | DataStore::recordUid(d->transaction, entity.identifier()); | 270 | DataStore::recordUid(d->transaction, entity.identifier(), type); |
271 | SinkTraceCtx(d->logCtx) << "Wrote entity: " << entity.identifier() << type << newRevision; | 271 | SinkTraceCtx(d->logCtx) << "Wrote entity: " << entity.identifier() << type << newRevision; |
272 | return true; | 272 | return true; |
273 | } | 273 | } |
@@ -379,7 +379,7 @@ bool EntityStore::remove(const QByteArray &type, const Sink::ApplicationDomain:: | |||
379 | [&](const DataStore::Error &error) { SinkWarningCtx(d->logCtx) << "Failed to write entity" << uid << newRevision; }); | 379 | [&](const DataStore::Error &error) { SinkWarningCtx(d->logCtx) << "Failed to write entity" << uid << newRevision; }); |
380 | DataStore::setMaxRevision(d->transaction, newRevision); | 380 | DataStore::setMaxRevision(d->transaction, newRevision); |
381 | DataStore::recordRevision(d->transaction, newRevision, uid, type); | 381 | DataStore::recordRevision(d->transaction, newRevision, uid, type); |
382 | DataStore::removeUid(d->transaction, uid); | 382 | DataStore::removeUid(d->transaction, uid, type); |
383 | return true; | 383 | return true; |
384 | } | 384 | } |
385 | 385 | ||
@@ -516,9 +516,8 @@ void EntityStore::readLatest(const QByteArray &type, const QByteArray &uid, cons | |||
516 | { | 516 | { |
517 | auto db = DataStore::mainDatabase(d->getTransaction(), type); | 517 | auto db = DataStore::mainDatabase(d->getTransaction(), type); |
518 | db.findLatest(uid, | 518 | db.findLatest(uid, |
519 | [=](const QByteArray &key, const QByteArray &value) -> bool { | 519 | [=](const QByteArray &key, const QByteArray &value) { |
520 | callback(DataStore::uidFromKey(key), Sink::EntityBuffer(value.data(), value.size())); | 520 | callback(DataStore::uidFromKey(key), Sink::EntityBuffer(value.data(), value.size())); |
521 | return false; | ||
522 | }, | 521 | }, |
523 | [&](const DataStore::Error &error) { SinkWarningCtx(d->logCtx) << "Error during query: " << error.message << uid; }); | 522 | [&](const DataStore::Error &error) { SinkWarningCtx(d->logCtx) << "Error during query: " << error.message << uid; }); |
524 | } | 523 | } |
@@ -639,7 +638,7 @@ ApplicationDomain::ApplicationDomainType EntityStore::readPrevious(const QByteAr | |||
639 | 638 | ||
640 | void EntityStore::readAllUids(const QByteArray &type, const std::function<void(const QByteArray &uid)> callback) | 639 | void EntityStore::readAllUids(const QByteArray &type, const std::function<void(const QByteArray &uid)> callback) |
641 | { | 640 | { |
642 | DataStore::getUids(d->getTransaction(), callback); | 641 | DataStore::getUids(type, d->getTransaction(), callback); |
643 | } | 642 | } |
644 | 643 | ||
645 | bool EntityStore::contains(const QByteArray &type, const QByteArray &uid) | 644 | bool EntityStore::contains(const QByteArray &type, const QByteArray &uid) |
@@ -653,7 +652,7 @@ bool EntityStore::exists(const QByteArray &type, const QByteArray &uid) | |||
653 | bool alreadyRemoved = false; | 652 | bool alreadyRemoved = false; |
654 | DataStore::mainDatabase(d->transaction, type) | 653 | DataStore::mainDatabase(d->transaction, type) |
655 | .findLatest(uid, | 654 | .findLatest(uid, |
656 | [&found, &alreadyRemoved](const QByteArray &key, const QByteArray &data) -> bool { | 655 | [&found, &alreadyRemoved](const QByteArray &key, const QByteArray &data) { |
657 | auto entity = GetEntity(data.data()); | 656 | auto entity = GetEntity(data.data()); |
658 | if (entity && entity->metadata()) { | 657 | if (entity && entity->metadata()) { |
659 | auto metadata = GetMetadata(entity->metadata()->Data()); | 658 | auto metadata = GetMetadata(entity->metadata()->Data()); |
@@ -662,7 +661,6 @@ bool EntityStore::exists(const QByteArray &type, const QByteArray &uid) | |||
662 | alreadyRemoved = true; | 661 | alreadyRemoved = true; |
663 | } | 662 | } |
664 | } | 663 | } |
665 | return false; | ||
666 | }, | 664 | }, |
667 | [&](const DataStore::Error &error) { SinkWarningCtx(d->logCtx) << "Failed to read old revision from storage: " << error.message; }); | 665 | [&](const DataStore::Error &error) { SinkWarningCtx(d->logCtx) << "Failed to read old revision from storage: " << error.message; }); |
668 | if (!found) { | 666 | if (!found) { |