diff options
Diffstat (limited to 'common/entitystorage.cpp')
-rw-r--r-- | common/entitystorage.cpp | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/common/entitystorage.cpp b/common/entitystorage.cpp index bcc3562..0eb2763 100644 --- a/common/entitystorage.cpp +++ b/common/entitystorage.cpp | |||
@@ -21,12 +21,8 @@ | |||
21 | 21 | ||
22 | static void scan(const Akonadi2::Storage::Transaction &transaction, const QByteArray &key, std::function<bool(const QByteArray &key, const Akonadi2::Entity &entity)> callback, const QByteArray &bufferType) | 22 | static void scan(const Akonadi2::Storage::Transaction &transaction, const QByteArray &key, std::function<bool(const QByteArray &key, const Akonadi2::Entity &entity)> callback, const QByteArray &bufferType) |
23 | { | 23 | { |
24 | transaction.openDatabase(bufferType + ".main").scan(key, [=](const QByteArray &key, const QByteArray &value) -> bool { | ||
25 | //Skip internals | ||
26 | if (Akonadi2::Storage::isInternalKey(key)) { | ||
27 | return true; | ||
28 | } | ||
29 | 24 | ||
25 | transaction.openDatabase(bufferType + ".main").findLatest(key, [=](const QByteArray &key, const QByteArray &value) -> bool { | ||
30 | //Extract buffers | 26 | //Extract buffers |
31 | Akonadi2::EntityBuffer buffer(value.data(), value.size()); | 27 | Akonadi2::EntityBuffer buffer(value.data(), value.size()); |
32 | 28 | ||
@@ -39,7 +35,9 @@ static void scan(const Akonadi2::Storage::Transaction &transaction, const QByteA | |||
39 | // qWarning() << "invalid buffer " << QByteArray::fromRawData(static_cast<char*>(keyValue), keySize); | 35 | // qWarning() << "invalid buffer " << QByteArray::fromRawData(static_cast<char*>(keyValue), keySize); |
40 | // return true; | 36 | // return true; |
41 | // } | 37 | // } |
42 | return callback(key, buffer.entity()); | 38 | // |
39 | //We're cutting the revision off the key | ||
40 | return callback(Akonadi2::Storage::uidFromKey(key), buffer.entity()); | ||
43 | }, | 41 | }, |
44 | [](const Akonadi2::Storage::Error &error) { | 42 | [](const Akonadi2::Storage::Error &error) { |
45 | qWarning() << "Error during query: " << error.message; | 43 | qWarning() << "Error during query: " << error.message; |
@@ -54,10 +52,11 @@ void EntityStorageBase::readValue(const Akonadi2::Storage::Transaction &transact | |||
54 | //This only works for a 1:1 mapping of resource to domain types. | 52 | //This only works for a 1:1 mapping of resource to domain types. |
55 | //Not i.e. for tags that are stored as flags in each entity of an imap store. | 53 | //Not i.e. for tags that are stored as flags in each entity of an imap store. |
56 | //additional properties that don't have a 1:1 mapping (such as separately stored tags), | 54 | //additional properties that don't have a 1:1 mapping (such as separately stored tags), |
57 | //could be added to the adaptor | 55 | //could be added to the adaptor. |
56 | |||
58 | auto domainObject = create(key, revision, mDomainTypeAdaptorFactory->createAdaptor(entity)); | 57 | auto domainObject = create(key, revision, mDomainTypeAdaptorFactory->createAdaptor(entity)); |
59 | resultCallback(domainObject); | 58 | resultCallback(domainObject); |
60 | return true; | 59 | return false; |
61 | }, mBufferType); | 60 | }, mBufferType); |
62 | } | 61 | } |
63 | 62 | ||
@@ -65,10 +64,18 @@ static ResultSet fullScan(const Akonadi2::Storage::Transaction &transaction, con | |||
65 | { | 64 | { |
66 | //TODO use a result set with an iterator, to read values on demand | 65 | //TODO use a result set with an iterator, to read values on demand |
67 | QVector<QByteArray> keys; | 66 | QVector<QByteArray> keys; |
68 | scan(transaction, QByteArray(), [=, &keys](const QByteArray &key, const Akonadi2::Entity &) { | 67 | transaction.openDatabase(bufferType + ".main").scan(QByteArray(), [&](const QByteArray &key, const QByteArray &value) -> bool { |
69 | keys << key; | 68 | //Skip internals |
69 | if (Akonadi2::Storage::isInternalKey(key)) { | ||
70 | return true; | ||
71 | } | ||
72 | keys << Akonadi2::Storage::uidFromKey(key); | ||
70 | return true; | 73 | return true; |
71 | }, bufferType); | 74 | }, |
75 | [](const Akonadi2::Storage::Error &error) { | ||
76 | qWarning() << "Error during query: " << error.message; | ||
77 | }); | ||
78 | |||
72 | Trace() << "Full scan found " << keys.size() << " results"; | 79 | Trace() << "Full scan found " << keys.size() << " results"; |
73 | return ResultSet(keys); | 80 | return ResultSet(keys); |
74 | } | 81 | } |