diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2018-01-30 11:27:33 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2018-01-30 15:28:55 +0100 |
commit | 33029ab13cdb378e2b4a0886a591fb02a5cb2b65 (patch) | |
tree | 1ffffda4f125fd4989856a9610d5843f5d097135 /common/storage_common.cpp | |
parent | f675a280ad48a9a2ba7b38f81cf0dfdafb3a96b5 (diff) | |
download | sink-33029ab13cdb378e2b4a0886a591fb02a5cb2b65.tar.gz sink-33029ab13cdb378e2b4a0886a591fb02a5cb2b65.zip |
Support for storage upgrades
Diffstat (limited to 'common/storage_common.cpp')
-rw-r--r-- | common/storage_common.cpp | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/common/storage_common.cpp b/common/storage_common.cpp index 630dae9..830eff2 100644 --- a/common/storage_common.cpp +++ b/common/storage_common.cpp | |||
@@ -233,9 +233,31 @@ bool DataStore::NamedDatabase::contains(const QByteArray &uid) | |||
233 | found = true; | 233 | found = true; |
234 | return false; | 234 | return false; |
235 | }, | 235 | }, |
236 | [this](const DataStore::Error &error) {}, true); | 236 | [](const DataStore::Error &error) {}, true); |
237 | return found; | 237 | return found; |
238 | } | 238 | } |
239 | 239 | ||
240 | void DataStore::setDatabaseVersion(DataStore::Transaction &transaction, qint64 revision) | ||
241 | { | ||
242 | transaction.openDatabase().write("__internal_databaseVersion", QByteArray::number(revision)); | ||
243 | } | ||
244 | |||
245 | qint64 DataStore::databaseVersion(const DataStore::Transaction &transaction) | ||
246 | { | ||
247 | qint64 r = 0; | ||
248 | transaction.openDatabase().scan("__internal_databaseVersion", | ||
249 | [&](const QByteArray &, const QByteArray &revision) -> bool { | ||
250 | r = revision.toLongLong(); | ||
251 | return false; | ||
252 | }, | ||
253 | [](const Error &error) { | ||
254 | if (error.code != DataStore::NotFound) { | ||
255 | SinkWarning() << "Couldn't find the database version: " << error; | ||
256 | } | ||
257 | }); | ||
258 | return r; | ||
259 | } | ||
260 | |||
261 | |||
240 | } | 262 | } |
241 | } // namespace Sink | 263 | } // namespace Sink |