diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-09-07 02:34:10 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-09-07 02:34:10 +0200 |
commit | a98311fbc807b83ecfc65a17f98464e5f1f9b3f8 (patch) | |
tree | a0c954404535fa832f7ddbd4f455fc67fe69bf4e /common | |
parent | 32c507fa0565547a187632db8a80c07babb95d9d (diff) | |
download | sink-a98311fbc807b83ecfc65a17f98464e5f1f9b3f8.tar.gz sink-a98311fbc807b83ecfc65a17f98464e5f1f9b3f8.zip |
Fixed getUids by type filtering.
We used to simply return all uids.
Requires "sinksh upgrade"
Diffstat (limited to 'common')
-rw-r--r-- | common/storage.h | 6 | ||||
-rw-r--r-- | common/storage/entitystore.cpp | 6 | ||||
-rw-r--r-- | common/storage_common.cpp | 12 |
3 files changed, 12 insertions, 12 deletions
diff --git a/common/storage.h b/common/storage.h index 8c129df..c39b904 100644 --- a/common/storage.h +++ b/common/storage.h | |||
@@ -198,9 +198,9 @@ public: | |||
198 | static QByteArray getTypeFromRevision(const Transaction &, qint64 revision); | 198 | static QByteArray getTypeFromRevision(const Transaction &, qint64 revision); |
199 | static void recordRevision(Transaction &, qint64 revision, const QByteArray &uid, const QByteArray &type); | 199 | static void recordRevision(Transaction &, qint64 revision, const QByteArray &uid, const QByteArray &type); |
200 | static void removeRevision(Transaction &, qint64 revision); | 200 | static void removeRevision(Transaction &, qint64 revision); |
201 | static void recordUid(DataStore::Transaction &transaction, const QByteArray &uid); | 201 | static void recordUid(DataStore::Transaction &transaction, const QByteArray &uid, const QByteArray &type); |
202 | static void removeUid(DataStore::Transaction &transaction, const QByteArray &uid); | 202 | static void removeUid(DataStore::Transaction &transaction, const QByteArray &uid, const QByteArray &type); |
203 | static void getUids(const Transaction &, const std::function<void(const QByteArray &uid)> &); | 203 | static void getUids(const QByteArray &type, const Transaction &, const std::function<void(const QByteArray &uid)> &); |
204 | 204 | ||
205 | bool exists() const; | 205 | bool exists() const; |
206 | 206 | ||
diff --git a/common/storage/entitystore.cpp b/common/storage/entitystore.cpp index 1ac87b7..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 | ||
@@ -638,7 +638,7 @@ ApplicationDomain::ApplicationDomainType EntityStore::readPrevious(const QByteAr | |||
638 | 638 | ||
639 | 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) |
640 | { | 640 | { |
641 | DataStore::getUids(d->getTransaction(), callback); | 641 | DataStore::getUids(type, d->getTransaction(), callback); |
642 | } | 642 | } |
643 | 643 | ||
644 | bool EntityStore::contains(const QByteArray &type, const QByteArray &uid) | 644 | bool EntityStore::contains(const QByteArray &type, const QByteArray &uid) |
diff --git a/common/storage_common.cpp b/common/storage_common.cpp index 8603787..630dae9 100644 --- a/common/storage_common.cpp +++ b/common/storage_common.cpp | |||
@@ -156,19 +156,19 @@ void DataStore::removeRevision(DataStore::Transaction &transaction, qint64 revis | |||
156 | transaction.openDatabase("revisionType").remove(QByteArray::number(revision)); | 156 | transaction.openDatabase("revisionType").remove(QByteArray::number(revision)); |
157 | } | 157 | } |
158 | 158 | ||
159 | void DataStore::recordUid(DataStore::Transaction &transaction, const QByteArray &uid) | 159 | void DataStore::recordUid(DataStore::Transaction &transaction, const QByteArray &uid, const QByteArray &type) |
160 | { | 160 | { |
161 | transaction.openDatabase("uids").write(uid, ""); | 161 | transaction.openDatabase(type + "uids").write(uid, ""); |
162 | } | 162 | } |
163 | 163 | ||
164 | void DataStore::removeUid(DataStore::Transaction &transaction, const QByteArray &uid) | 164 | void DataStore::removeUid(DataStore::Transaction &transaction, const QByteArray &uid, const QByteArray &type) |
165 | { | 165 | { |
166 | transaction.openDatabase("uids").remove(uid); | 166 | transaction.openDatabase(type + "uids").remove(uid); |
167 | } | 167 | } |
168 | 168 | ||
169 | void DataStore::getUids(const Transaction &transaction, const std::function<void(const QByteArray &uid)> &callback) | 169 | void DataStore::getUids(const QByteArray &type, const Transaction &transaction, const std::function<void(const QByteArray &uid)> &callback) |
170 | { | 170 | { |
171 | transaction.openDatabase("uids").scan("", [&] (const QByteArray &key, const QByteArray &) { | 171 | transaction.openDatabase(type + "uids").scan("", [&] (const QByteArray &key, const QByteArray &) { |
172 | callback(key); | 172 | callback(key); |
173 | return true; | 173 | return true; |
174 | }); | 174 | }); |