diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-05-06 12:37:30 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-05-06 12:37:30 +0200 |
commit | f52ed4fd64994985f1061c5fcd20dccaa61fbc67 (patch) | |
tree | 037ab2cff55452dfcfb1eae772458ebab020d749 /common/storage/entitystore.cpp | |
parent | 8eab2b67fdf83c657f996debfc238703a78b337b (diff) | |
download | sink-f52ed4fd64994985f1061c5fcd20dccaa61fbc67.tar.gz sink-f52ed4fd64994985f1061c5fcd20dccaa61fbc67.zip |
A defined table layout
Diffstat (limited to 'common/storage/entitystore.cpp')
-rw-r--r-- | common/storage/entitystore.cpp | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/common/storage/entitystore.cpp b/common/storage/entitystore.cpp index 04760f7..9539bec 100644 --- a/common/storage/entitystore.cpp +++ b/common/storage/entitystore.cpp | |||
@@ -36,6 +36,33 @@ | |||
36 | using namespace Sink; | 36 | using namespace Sink; |
37 | using namespace Sink::Storage; | 37 | using namespace Sink::Storage; |
38 | 38 | ||
39 | static Sink::Storage::DbLayout dbLayout(const QByteArray &instanceId) | ||
40 | { | ||
41 | return Sink::Storage::DbLayout { | ||
42 | instanceId, | ||
43 | { | ||
44 | {"folder.main", 0}, | ||
45 | {"folder.index.name", 1}, | ||
46 | {"folder.index.parent", 1}, | ||
47 | {"mail.main", 0}, | ||
48 | {"mail.index.date", 1}, | ||
49 | {"mail.index.folder", 1}, | ||
50 | {"mail.index.folder.sort.date", 0}, | ||
51 | {"mail.index.messageId", 1}, | ||
52 | {"mail.index.messageIdthreadId", 1}, | ||
53 | {"mail.index.parentMessageId", 1}, | ||
54 | {"mail.index.subjectthreadId", 1}, | ||
55 | {"mail.index.threadIdmessageId", 1}, | ||
56 | {"revisionType", 0}, | ||
57 | {"revisions", 0}, | ||
58 | {"uids", 0}, | ||
59 | {"default", 0}, | ||
60 | {"__flagtable", 0} | ||
61 | } | ||
62 | }; | ||
63 | } | ||
64 | |||
65 | |||
39 | class EntityStore::Private { | 66 | class EntityStore::Private { |
40 | public: | 67 | public: |
41 | Private(const ResourceContext &context, const Sink::Log::Context &ctx) : resourceContext(context), logCtx(ctx.subContext("entitystore")) {} | 68 | Private(const ResourceContext &context, const Sink::Log::Context &ctx) : resourceContext(context), logCtx(ctx.subContext("entitystore")) {} |
@@ -47,7 +74,7 @@ public: | |||
47 | 74 | ||
48 | bool exists() | 75 | bool exists() |
49 | { | 76 | { |
50 | return Sink::Storage::DataStore(Sink::storageLocation(), resourceContext.instanceId(), DataStore::ReadOnly).exists(); | 77 | return Sink::Storage::DataStore(Sink::storageLocation(), dbLayout(resourceContext.instanceId()), DataStore::ReadOnly).exists(); |
51 | } | 78 | } |
52 | 79 | ||
53 | DataStore::Transaction &getTransaction() | 80 | DataStore::Transaction &getTransaction() |
@@ -56,7 +83,7 @@ public: | |||
56 | return transaction; | 83 | return transaction; |
57 | } | 84 | } |
58 | 85 | ||
59 | Sink::Storage::DataStore store(Sink::storageLocation(), resourceContext.instanceId(), DataStore::ReadOnly); | 86 | Sink::Storage::DataStore store(Sink::storageLocation(), dbLayout(resourceContext.instanceId()), DataStore::ReadOnly); |
60 | transaction = store.createTransaction(DataStore::ReadOnly); | 87 | transaction = store.createTransaction(DataStore::ReadOnly); |
61 | return transaction; | 88 | return transaction; |
62 | } | 89 | } |
@@ -110,7 +137,7 @@ void EntityStore::startTransaction(Sink::Storage::DataStore::AccessMode accessMo | |||
110 | { | 137 | { |
111 | SinkTraceCtx(d->logCtx) << "Starting transaction: " << accessMode; | 138 | SinkTraceCtx(d->logCtx) << "Starting transaction: " << accessMode; |
112 | Q_ASSERT(!d->transaction); | 139 | Q_ASSERT(!d->transaction); |
113 | Sink::Storage::DataStore store(Sink::storageLocation(), d->resourceContext.instanceId(), accessMode); | 140 | Sink::Storage::DataStore store(Sink::storageLocation(), dbLayout(d->resourceContext.instanceId()), accessMode); |
114 | d->transaction = store.createTransaction(accessMode); | 141 | d->transaction = store.createTransaction(accessMode); |
115 | } | 142 | } |
116 | 143 | ||