diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2018-03-26 11:24:57 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2018-03-26 11:24:57 +0200 |
commit | a0237dbe6fb904aac1338ecc1aae2dbe0900ac3f (patch) | |
tree | 6c00d48b8d7b07907e46b81649ff05d89667a0aa /common/genericresource.cpp | |
parent | 0f6f34ca2fca81734544b32e8dbc8ee32122bb65 (diff) | |
download | sink-a0237dbe6fb904aac1338ecc1aae2dbe0900ac3f.tar.gz sink-a0237dbe6fb904aac1338ecc1aae2dbe0900ac3f.zip |
Avoid a database upgrade when creating the db first.
By setting the database version initially.
Diffstat (limited to 'common/genericresource.cpp')
-rw-r--r-- | common/genericresource.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/common/genericresource.cpp b/common/genericresource.cpp index 97ce968..5f49814 100644 --- a/common/genericresource.cpp +++ b/common/genericresource.cpp | |||
@@ -58,10 +58,10 @@ void GenericResource::setSecret(const QString &s) | |||
58 | 58 | ||
59 | bool GenericResource::checkForUpgrade() | 59 | bool GenericResource::checkForUpgrade() |
60 | { | 60 | { |
61 | const auto currentDatabaseVersion = [&] { | 61 | auto store = Sink::Storage::DataStore(Sink::storageLocation(), mResourceContext.instanceId(), Sink::Storage::DataStore::ReadOnly); |
62 | auto store = Sink::Storage::DataStore(Sink::storageLocation(), mResourceContext.instanceId(), Sink::Storage::DataStore::ReadOnly); | 62 | //We rely on the store already having been created in the pipeline constructor before this get's called. |
63 | return Storage::DataStore::databaseVersion(store.createTransaction(Storage::DataStore::ReadOnly)); | 63 | Q_ASSERT(store.exists()); |
64 | }(); | 64 | const auto currentDatabaseVersion = Storage::DataStore::databaseVersion(store.createTransaction(Storage::DataStore::ReadOnly)); |
65 | if (currentDatabaseVersion != Sink::latestDatabaseVersion()) { | 65 | if (currentDatabaseVersion != Sink::latestDatabaseVersion()) { |
66 | SinkLog() << "Starting database upgrade from " << currentDatabaseVersion << " to " << Sink::latestDatabaseVersion(); | 66 | SinkLog() << "Starting database upgrade from " << currentDatabaseVersion << " to " << Sink::latestDatabaseVersion(); |
67 | 67 | ||