diff options
author | Minijackson <minijackson@riseup.net> | 2018-06-27 11:12:38 +0200 |
---|---|---|
committer | Minijackson <minijackson@riseup.net> | 2018-07-04 15:37:14 +0200 |
commit | 016fea734d09df707be9a16a4ad6a1107f41549f (patch) | |
tree | 60bf9767842713538505fca80515a8f5e59ca985 /common/storage/entitystore.cpp | |
parent | c90ba4a98292a39eb0b3df12fd7e2dec0300e58d (diff) | |
download | sink-016fea734d09df707be9a16a4ad6a1107f41549f.tar.gz sink-016fea734d09df707be9a16a4ad6a1107f41549f.zip |
Fix pipelinetest + remove useless commented lines
Diffstat (limited to 'common/storage/entitystore.cpp')
-rw-r--r-- | common/storage/entitystore.cpp | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/common/storage/entitystore.cpp b/common/storage/entitystore.cpp index efafe8a..d3420e4 100644 --- a/common/storage/entitystore.cpp +++ b/common/storage/entitystore.cpp | |||
@@ -371,8 +371,9 @@ void EntityStore::cleanupEntityRevisionsUntil(qint64 revision) | |||
371 | return; | 371 | return; |
372 | } | 372 | } |
373 | SinkTraceCtx(d->logCtx) << "Cleaning up revision " << revision << uid << bufferType; | 373 | SinkTraceCtx(d->logCtx) << "Cleaning up revision " << revision << uid << bufferType; |
374 | const auto internalUid = Identifier::fromDisplayByteArray(uid).toInternalByteArray(); | ||
374 | DataStore::mainDatabase(d->transaction, bufferType) | 375 | DataStore::mainDatabase(d->transaction, bufferType) |
375 | .scan(uid, | 376 | .scan(internalUid, |
376 | [&](const QByteArray &key, const QByteArray &data) -> bool { | 377 | [&](const QByteArray &key, const QByteArray &data) -> bool { |
377 | EntityBuffer buffer(const_cast<const char *>(data.data()), data.size()); | 378 | EntityBuffer buffer(const_cast<const char *>(data.data()), data.size()); |
378 | if (!buffer.isValid()) { | 379 | if (!buffer.isValid()) { |
@@ -530,7 +531,6 @@ ApplicationDomain::ApplicationDomainType EntityStore::readLatest(const QByteArra | |||
530 | return dt; | 531 | return dt; |
531 | } | 532 | } |
532 | 533 | ||
533 | // TODO: check every usage | ||
534 | void EntityStore::readEntity(const QByteArray &type, const QByteArray &displayKey, const std::function<void(const QByteArray &uid, const EntityBuffer &entity)> callback) | 534 | void EntityStore::readEntity(const QByteArray &type, const QByteArray &displayKey, const std::function<void(const QByteArray &uid, const EntityBuffer &entity)> callback) |
535 | { | 535 | { |
536 | const auto key = Key::fromDisplayByteArray(displayKey); | 536 | const auto key = Key::fromDisplayByteArray(displayKey); |
@@ -598,7 +598,6 @@ void EntityStore::readPrevious(const QByteArray &type, const QByteArray &uid, qi | |||
598 | const auto internalUid = Identifier::fromDisplayByteArray(uid).toInternalByteArray(); | 598 | const auto internalUid = Identifier::fromDisplayByteArray(uid).toInternalByteArray(); |
599 | db.scan(internalUid, | 599 | db.scan(internalUid, |
600 | [&latestRevision, revision](const QByteArray &key, const QByteArray &) -> bool { | 600 | [&latestRevision, revision](const QByteArray &key, const QByteArray &) -> bool { |
601 | //const auto foundRevision = DataStore::revisionFromKey(key); | ||
602 | const auto foundRevision = Key::fromInternalByteArray(key).revision().toQint64(); | 601 | const auto foundRevision = Key::fromInternalByteArray(key).revision().toQint64(); |
603 | if (foundRevision < revision && foundRevision > latestRevision) { | 602 | if (foundRevision < revision && foundRevision > latestRevision) { |
604 | latestRevision = foundRevision; | 603 | latestRevision = foundRevision; |
@@ -633,11 +632,7 @@ void EntityStore::readAllUids(const QByteArray &type, const std::function<void(c | |||
633 | 632 | ||
634 | bool EntityStore::contains(const QByteArray &type, const QByteArray &uid) | 633 | bool EntityStore::contains(const QByteArray &type, const QByteArray &uid) |
635 | { | 634 | { |
636 | // Because of pipeline using this function with new entities | 635 | Q_ASSERT(!uid.isEmpty()); |
637 | // TODO: maybe modify pipeline instead? | ||
638 | if(uid.isEmpty()) { | ||
639 | return false; | ||
640 | } | ||
641 | const auto internalUid = Identifier::fromDisplayByteArray(uid).toInternalByteArray(); | 636 | const auto internalUid = Identifier::fromDisplayByteArray(uid).toInternalByteArray(); |
642 | return DataStore::mainDatabase(d->getTransaction(), type).contains(internalUid); | 637 | return DataStore::mainDatabase(d->getTransaction(), type).contains(internalUid); |
643 | } | 638 | } |
@@ -675,10 +670,11 @@ void EntityStore::readRevisions(const QByteArray &type, const QByteArray &uid, q | |||
675 | { | 670 | { |
676 | Q_ASSERT(d); | 671 | Q_ASSERT(d); |
677 | Q_ASSERT(!uid.isEmpty()); | 672 | Q_ASSERT(!uid.isEmpty()); |
673 | const auto internalUid = Identifier::fromDisplayByteArray(uid).toInternalByteArray(); | ||
678 | DataStore::mainDatabase(d->transaction, type) | 674 | DataStore::mainDatabase(d->transaction, type) |
679 | .scan(uid, | 675 | .scan(internalUid, |
680 | [&](const QByteArray &key, const QByteArray &value) -> bool { | 676 | [&](const QByteArray &key, const QByteArray &value) -> bool { |
681 | const auto parsedKey = Key::fromDisplayByteArray(key); | 677 | const auto parsedKey = Key::fromInternalByteArray(key); |
682 | const auto revision = parsedKey.revision().toQint64(); | 678 | const auto revision = parsedKey.revision().toQint64(); |
683 | if (revision >= startingRevision) { | 679 | if (revision >= startingRevision) { |
684 | callback(parsedKey.identifier().toDisplayByteArray(), revision, Sink::EntityBuffer(value.data(), value.size())); | 680 | callback(parsedKey.identifier().toDisplayByteArray(), revision, Sink::EntityBuffer(value.data(), value.size())); |