diff options
Diffstat (limited to 'common/storage_common.cpp')
-rw-r--r-- | common/storage_common.cpp | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/common/storage_common.cpp b/common/storage_common.cpp index 81a38c7..8603787 100644 --- a/common/storage_common.cpp +++ b/common/storage_common.cpp | |||
@@ -24,8 +24,6 @@ | |||
24 | #include "log.h" | 24 | #include "log.h" |
25 | #include <QUuid> | 25 | #include <QUuid> |
26 | 26 | ||
27 | SINK_DEBUG_AREA("storage") | ||
28 | |||
29 | QDebug& operator<<(QDebug &dbg, const Sink::Storage::DataStore::Error &error) | 27 | QDebug& operator<<(QDebug &dbg, const Sink::Storage::DataStore::Error &error) |
30 | { | 28 | { |
31 | dbg << error.message << "Code: " << error.code << "Db: " << error.store; | 29 | dbg << error.message << "Code: " << error.code << "Db: " << error.store; |
@@ -38,6 +36,18 @@ namespace Storage { | |||
38 | static const char *s_internalPrefix = "__internal"; | 36 | static const char *s_internalPrefix = "__internal"; |
39 | static const int s_internalPrefixSize = strlen(s_internalPrefix); | 37 | static const int s_internalPrefixSize = strlen(s_internalPrefix); |
40 | 38 | ||
39 | DbLayout::DbLayout() | ||
40 | { | ||
41 | |||
42 | } | ||
43 | |||
44 | DbLayout::DbLayout(const QByteArray &n, const Databases &t) | ||
45 | : name(n), | ||
46 | tables(t) | ||
47 | { | ||
48 | |||
49 | } | ||
50 | |||
41 | void errorHandler(const DataStore::Error &error) | 51 | void errorHandler(const DataStore::Error &error) |
42 | { | 52 | { |
43 | if (error.code == DataStore::TransactionError) { | 53 | if (error.code == DataStore::TransactionError) { |
@@ -113,7 +123,7 @@ QByteArray DataStore::getUidFromRevision(const DataStore::Transaction &transacti | |||
113 | transaction.openDatabase("revisions") | 123 | transaction.openDatabase("revisions") |
114 | .scan(QByteArray::number(revision), | 124 | .scan(QByteArray::number(revision), |
115 | [&](const QByteArray &, const QByteArray &value) -> bool { | 125 | [&](const QByteArray &, const QByteArray &value) -> bool { |
116 | uid = value; | 126 | uid = QByteArray{value.constData(), value.size()}; |
117 | return false; | 127 | return false; |
118 | }, | 128 | }, |
119 | [revision](const Error &error) { SinkWarning() << "Couldn't find uid for revision: " << revision << error.message; }); | 129 | [revision](const Error &error) { SinkWarning() << "Couldn't find uid for revision: " << revision << error.message; }); |
@@ -126,7 +136,7 @@ QByteArray DataStore::getTypeFromRevision(const DataStore::Transaction &transact | |||
126 | transaction.openDatabase("revisionType") | 136 | transaction.openDatabase("revisionType") |
127 | .scan(QByteArray::number(revision), | 137 | .scan(QByteArray::number(revision), |
128 | [&](const QByteArray &, const QByteArray &value) -> bool { | 138 | [&](const QByteArray &, const QByteArray &value) -> bool { |
129 | type = value; | 139 | type = QByteArray{value.constData(), value.size()}; |
130 | return false; | 140 | return false; |
131 | }, | 141 | }, |
132 | [revision](const Error &error) { SinkWarning() << "Couldn't find type for revision " << revision; }); | 142 | [revision](const Error &error) { SinkWarning() << "Couldn't find type for revision " << revision; }); |
@@ -207,6 +217,11 @@ QByteArray DataStore::generateUid() | |||
207 | 217 | ||
208 | DataStore::NamedDatabase DataStore::mainDatabase(const DataStore::Transaction &t, const QByteArray &type) | 218 | DataStore::NamedDatabase DataStore::mainDatabase(const DataStore::Transaction &t, const QByteArray &type) |
209 | { | 219 | { |
220 | if (type.isEmpty()) { | ||
221 | SinkError() << "Tried to open main database for empty type."; | ||
222 | Q_ASSERT(false); | ||
223 | return {}; | ||
224 | } | ||
210 | return t.openDatabase(type + ".main"); | 225 | return t.openDatabase(type + ".main"); |
211 | } | 226 | } |
212 | 227 | ||